| 1 |
############################################################################ |
|---|
| 2 |
# |
|---|
| 3 |
# Copyright (c) 2005-2006 Nuxeo and Contributors. |
|---|
| 4 |
# All Rights Reserved. |
|---|
| 5 |
# |
|---|
| 6 |
# This software is subject to the provisions of the Zope Public License, |
|---|
| 7 |
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
|---|
| 8 |
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
|---|
| 9 |
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|---|
| 10 |
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
|---|
| 11 |
# FOR A PARTICULAR PURPOSE. |
|---|
| 12 |
# |
|---|
| 13 |
############################################################################## |
|---|
| 14 |
""" |
|---|
| 15 |
|
|---|
| 16 |
$Id$ |
|---|
| 17 |
""" |
|---|
| 18 |
__docformat__ = "reStructuredText" |
|---|
| 19 |
|
|---|
| 20 |
from xml.dom.minidom import parseString |
|---|
| 21 |
|
|---|
| 22 |
from zope.app.publisher.browser import BrowserView |
|---|
| 23 |
from zope.component import adapts |
|---|
| 24 |
from zope.component.factory import Factory |
|---|
| 25 |
from zope.interface import implements, implementedBy |
|---|
| 26 |
|
|---|
| 27 |
from cpsskins.perspectives.interfaces import IPerspective |
|---|
| 28 |
from cpsskins.relations.interfaces import IRelatable |
|---|
| 29 |
|
|---|
| 30 |
class Perspective(object): |
|---|
| 31 |
"""A perspective |
|---|
| 32 |
|
|---|
| 33 |
>>> perspective = Perspective(name=u'cpsskins.perspective') |
|---|
| 34 |
>>> perspective |
|---|
| 35 |
<Perspective: 'cpsskins.perspective'> |
|---|
| 36 |
|
|---|
| 37 |
""" |
|---|
| 38 |
implements(IPerspective) |
|---|
| 39 |
|
|---|
| 40 |
def __init__(self, name=u'', title=u''): |
|---|
| 41 |
self.name = name |
|---|
| 42 |
self.title = title |
|---|
| 43 |
|
|---|
| 44 |
def __repr__(self): |
|---|
| 45 |
return "<Perspective: '%s'>" % str(self) |
|---|
| 46 |
|
|---|
| 47 |
def __str__(self): |
|---|
| 48 |
return self.name |
|---|
| 49 |
|
|---|
| 50 |
def __eq__(self, other): |
|---|
| 51 |
return str(self) == other |
|---|
| 52 |
|
|---|
| 53 |
PerspectiveFactory = Factory(Perspective, "Perspective Factory", |
|---|
| 54 |
"Factory that creates Perspectives") |
|---|
| 55 |
|
|---|
| 56 |
class Relatable(object): |
|---|
| 57 |
"""This adapter makes perspectives relatable. |
|---|
| 58 |
""" |
|---|
| 59 |
adapts(IPerspective) |
|---|
| 60 |
implements(IRelatable) |
|---|
| 61 |
|
|---|
| 62 |
def __init__(self, context): |
|---|
| 63 |
self.context = context |
|---|
| 64 |
|
|---|
| 65 |
def __str__(self): |
|---|
| 66 |
return str(self.context) |
|---|
| 67 |
|
|---|