Author: jmorliaguet Date: Thu Oct 20 14:31:33 2005 New Revision: 28447 Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/__init__.py z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/cell_edit_layout.pt z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/pageblock_edit_layout.pt z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/portlet_editor.pt z3lab/cpsskins/branches/jmo-perspectives/browser/elements/__init__.py z3lab/cpsskins/branches/jmo-perspectives/browser/elements/slot.py z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/interfaces.py z3lab/cpsskins/branches/jmo-perspectives/configuration/portlets/metaconfigure.py z3lab/cpsskins/branches/jmo-perspectives/configuration/portlets/metadirectives.py z3lab/cpsskins/branches/jmo-perspectives/controllers/portlet.py z3lab/cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt z3lab/cpsskins/branches/jmo-perspectives/elements/__init__.py z3lab/cpsskins/branches/jmo-perspectives/elements/displays/__init__.py z3lab/cpsskins/branches/jmo-perspectives/elements/displays/boxgroup.py z3lab/cpsskins/branches/jmo-perspectives/elements/formats/style.py z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py z3lab/cpsskins/branches/jmo-perspectives/elements/portlet.py z3lab/cpsskins/branches/jmo-perspectives/elements/slot.py z3lab/cpsskins/branches/jmo-perspectives/engines/common/filters/effect/__init__.py z3lab/cpsskins/branches/jmo-perspectives/engines/common/filters/style/__init__.py z3lab/cpsskins/branches/jmo-perspectives/engines/jsr168/filters/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/configure.zcml z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/configure.zcml z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/configure.zcml z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/configure.zcml z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/image/configure.zcml z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/configure.zcml z3lab/cpsskins/branches/jmo-perspectives/thememanager.py Log:
- saving work: - some cleanup in elements.portlet - small portlet API adjustments Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/__init__.py Thu Oct 20 14:31:33 2005 @@ -150,7 +150,7 @@ def getId(self): """Return the element's id """ - return self.context.getIdentifier() + return self.context.identifier def getPath(self): """Return the element's path @@ -238,7 +238,7 @@ adding = getMultiAdapter((container, request), INodeAdding) added = adding.add(content) - added_id = added.getIdentifier() + added_id = added.identifier self.reorderElement(added_id, int(order)) return added_id @@ -254,7 +254,7 @@ moved = moving.move(element) # move the element to the specified order - moved_id = moved.getIdentifier() + moved_id = moved.identifier self.reorderElement(moved_id, int(order)) return moved_id Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/cell_edit_layout.pt ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/cell_edit_layout.pt (original) +++ z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/cell_edit_layout.pt Thu Oct 20 14:31:33 2005 @@ -11,7 +11,7 @@ title context/title; id view/getId; layout nocall:options/layout; - layout_id layout/getIdentifier; + layout_id layout/identifier; width layout/width" tal:attributes=" editable python:1; Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/pageblock_edit_layout.pt ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/pageblock_edit_layout.pt (original) +++ z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/pageblock_edit_layout.pt Thu Oct 20 14:31:33 2005 @@ -10,7 +10,7 @@ title context/title; layout nocall:options/layout; this_id view/getId; - layout_id layout/getIdentifier; + layout_id layout/identifier; width layout/width"> <table tal:condition="not:mode_is_layout" cellpadding="0" cellspacing="0" Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/portlet_editor.pt ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/portlet_editor.pt (original) +++ z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/portlet_editor.pt Thu Oct 20 14:31:33 2005 @@ -17,7 +17,7 @@ <head> <body onload="javascript:showPreview()" metal:fill-slot="body" i18n:domain="cpsskins" - tal:define="element_id context/getIdentifier"> + tal:define="element_id context/identifier"> <!-- Edit area --> <div class="editArea"> Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/elements/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/browser/elements/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/browser/elements/__init__.py Thu Oct 20 14:31:33 2005 @@ -85,5 +85,5 @@ # move the copied element just below the original element reordering = getMultiAdapter((container, request), INodeOrdering) reordering.reorder(copied, int(content_order)+1) - return copied.getIdentifier() + return copied.identifier Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/elements/slot.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/browser/elements/slot.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/browser/elements/slot.py Thu Oct 20 14:31:33 2005 @@ -270,5 +270,5 @@ duplicated.__parent__ = container - return duplicated.getIdentifier() + return duplicated.identifier Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/engine.py Thu Oct 20 14:31:33 2005 @@ -19,7 +19,7 @@ from zope.app.traversing.api import getParent from zope.app.zapi import getMultiAdapter, queryMultiAdapter -from zope.component import adapts, getUtility +from zope.component import adapts, getUtility, adaptedBy from zope.configuration.exceptions import ConfigurationError from zope.interface import implements from zope.publisher.interfaces import IRequest @@ -27,7 +27,7 @@ from cpsskins.browser.negociation.interfaces import INegociation from cpsskins.browser.rendering.interfaces import IDisplayData from cpsskins.configuration.interfaces import IRegistry -from cpsskins.elements.interfaces import IElement, ISlot, IDisplayable +from cpsskins.elements.interfaces import IElement, ILeaf, ISlot, IDisplayable from cpsskins.relations.interfaces import IPredicate from cpsskins.storage.interfaces import IRelationStorage from cpsskins.thememanager import getThemeManager @@ -41,12 +41,15 @@ filter_registry = getUtility(IRegistry, 'filters') renderer_registry = getUtility(IRegistry, 'renderers') -class Context(object): +class ContextInfo: """A transient object that holds information used by a renderer. - >>> c = Context({'element': 'some element', - ... 'display': 'some display', - ... }) + It can be accessed as a dictionary or as an object with attributes + + >>> c = ContextInfo({ + ... 'element': 'some element', + ... 'display': 'some display', + ... }) >>> c.element 'some element' @@ -57,7 +60,7 @@ >>> c.style Traceback (most recent call last): ... - AttributeError: No such value in this context + AttributeError: No such variable 'style' in this context >>> c.style = 'some style' >>> c.style @@ -66,6 +69,10 @@ >>> c.contexts {'display': 'some display', 'element': 'some element'} + >>> c.update({'display': 'some other display'}) + >>> c.contexts + {'display': 'some other display', 'element': 'some element'} + """ implements(IContextInfo) @@ -79,10 +86,15 @@ if name in self.contexts: return self.contexts[name] else: - raise AttributeError, "No such value in this context" + raise AttributeError( + "No such variable '%s' in this context" % name) + + def update(self, map): + for k, v in map.items(): + self[k] = v def __repr__(self): - return 'Renderer context at %s' % hex(id(self)) + return '<Renderer context info at %s>' % hex(id(self)) class Renderer(object): """A renderer is a collection of filters. It provides some rendering @@ -93,10 +105,8 @@ def __init__(self, context, request): element = context - perspective = getMultiAdapter( - objects=(context, request), - interface=INegociation, - ).getPerspective() + perspective = getMultiAdapter((context, request), + INegociation).getPerspective() displayable = IDisplayable(element) display = displayable.getEffectiveDisplay(perspective) @@ -107,7 +117,7 @@ if display is None and ISlot.providedBy(parent): display = IDisplayable(parent).getEffectiveDisplay(perspective) - self.info = Context( + self.info = ContextInfo( {'request': request, 'element': element, 'display': display, @@ -121,9 +131,7 @@ """Get the list of filters """ info = self.info - element = info.element - display = info.display - request = info.request + element, display, request = info.element, info.display, info.request if display is None: return [] @@ -146,9 +154,7 @@ % (filter_id, len(filter_id)) ) continue - res = relations.search( - predicate=filter_id, - first=display) + res = relations.search(predicate=filter_id, first=display) if not res: continue adapted = relations[res[0]].second @@ -164,8 +170,7 @@ logger.log(INFO, "Filter '%s' will not be applied. " "No IFilter adapter was found for '%s'." - % (filter_name, repr(adapted)) - ) + % (filter_name, repr(adapted))) continue # the filter id refers to an adapter @@ -174,8 +179,7 @@ else: raise ConfigurationError( - "The '%s' filter id is not supported." % repr(filter_id) - ) + "The '%s' filter id is not supported." % repr(filter_id)) filters.append(filter) return filters @@ -184,23 +188,23 @@ """Do the actual rendering by applying all filters. """ info = self.info - request = info.request - element = info.element - # context info - info.location = kw.get('location') - info.template = kw.get('template') - info.view = kw.get('view') - - # XXX this can be cached. - tmutil = getThemeManager() - theme = tmutil.getThemeInContext(element) - - if element.isLeaf(): - display_data = getMultiAdapter( - objects=(element, info), - interface=IDisplayData, - ) + # set global parameters + info.update({ + 'view': kw.get('view'), + 'location': kw.get('location'), + 'template': kw.get('template'), + 'engine': kw.get('engine', 'default'), + }) + + # these have been set in __init__() + element, request = (info.element, info.request) + + # TODO this can be cached. + theme = getThemeManager().getThemeInContext(element) + + if ILeaf.providedBy(element): + display_data = getMultiAdapter((element, info), IDisplayData) if callable(display_data): rendered = display_data(**kw) else: @@ -210,7 +214,7 @@ rendered.append(renderer(**kw)) rendered = ''.join(rendered) - engine = kw.get('engine', 'default') + engine = info.engine # look for renderers associated to the element's content type iface = element.getContentType() Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/interfaces.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/interfaces.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/browser/rendering/interfaces.py Thu Oct 20 14:31:33 2005 @@ -30,6 +30,9 @@ class IContextInfo(Interface): """Some information about the element being rendered""" + def update(map): + """Update map entries.""" + class IDisplayData(Interface): """Information used by filters for generating some output to display.""" Modified: z3lab/cpsskins/branches/jmo-perspectives/configuration/portlets/metaconfigure.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/configuration/portlets/metaconfigure.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/configuration/portlets/metaconfigure.py Thu Oct 20 14:31:33 2005 @@ -21,11 +21,11 @@ from zope.app.annotation.interfaces import IAttributeAnnotatable from zope.app.form.browser.metaconfigure import EditFormDirective +from zope.app.component.contentdirective import ContentDirective from zope.app.component.metaconfigure import adapter from zope.app.publisher.browser.icon import IconDirective from zope.app.publisher.browser.menumeta import addMenuItem from zope.app.publisher.browser.resourcemeta import resource -from zope.app.component.contentdirective import ContentDirective from zope.app.content.interfaces import IContentType from zope.configuration.exceptions import ConfigurationError from zope.interface import classImplements, Interface, alsoProvides @@ -41,7 +41,6 @@ description=None, factory=None, schema=None, - data=None, icon=None): if not name: @@ -59,9 +58,6 @@ if not schema: raise ConfigurationError("Must specify a portlet schema.") - if not data: - raise ConfigurationError("Must specify a display data class.") - if not icon: raise ConfigurationError("Must specify a portlet icon.") @@ -111,14 +107,5 @@ permission="zope.ManageContent", set_schema=(schema,)) - # zope:adapter - adapter(_context=_context, - factory=(data,), - provides=IDisplayData, - for_=(schema, IContextInfo), - ) - - classImplements(factory, schema) - # set up interface types alsoProvides(schema, IContentType) Modified: z3lab/cpsskins/branches/jmo-perspectives/configuration/portlets/metadirectives.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/configuration/portlets/metadirectives.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/configuration/portlets/metadirectives.py Thu Oct 20 14:31:33 2005 @@ -16,11 +16,12 @@ $Id$ """ __docformat__ = "reStructuredText" + from zope.interface import Interface +from zope.i18nmessageid import MessageFactory from zope.configuration.fields import GlobalObject, GlobalInterface, Path from zope.schema import TextLine -from zope.i18nmessageid import MessageFactory _ = MessageFactory("cpsskins") class IPortletDirective(Interface): @@ -58,12 +59,6 @@ required=False, ) - data = GlobalObject( - title=_("Display data"), - description=_("Display data generated by the portlet"), - required=False, - ) - icon = Path( title=_("Icon"), description=_("The portlet's icon"), Modified: z3lab/cpsskins/branches/jmo-perspectives/controllers/portlet.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/controllers/portlet.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/controllers/portlet.py Thu Oct 20 14:31:33 2005 @@ -33,8 +33,7 @@ def created(self): element = self.element - element.setIdentifier(None) - element.title = '' + element.identifier = None def added(self): """What to do when the element has been added. Modified: z3lab/cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt (original) +++ z3lab/cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt Thu Oct 20 14:31:33 2005 @@ -29,9 +29,9 @@ to obtain the data, the portlet's __call__() method is called: - >>> from cpsskins.browser.rendering.engine import Context + >>> from cpsskins.browser.rendering.engine import ContextInfo >>> from cpsskins.browser.rendering.interfaces import IDisplayData - >>> info = Context({'request': request, 'data': None, 'metadata': None}) + >>> info = ContextInfo({'request': request, 'data': None, 'metadata': None}) >>> data = getMultiAdapter((portlet, info), IDisplayData) >>> data() Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/elements/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/elements/__init__.py Thu Oct 20 14:31:33 2005 @@ -34,11 +34,10 @@ """ implements(IElement) - def __init__(self): - self._identifier = None + identifier = None def __str__(self): - id = self.getIdentifier() or '' + id = getattr(self, 'identifier', '') return str(id) def edit(self, k, v): @@ -50,15 +49,6 @@ def name(self): return zapi.name(self) - def getIdentifier(self): - return self._identifier - - def setIdentifier(self, id): - self._identifier = id - - def isIdenticalTo(self, other): - return self._identifier == other._identifier - def getElementType(self): return queryType(self, IElementType) @@ -86,7 +76,7 @@ """Return the ordered tree data structure starting from this element. Elements are identified by their unique identifier. """ - index = [self.getIdentifier()] + index = [self.identifier] if isinstance(self, Leaf): return index for node in self.getChildNodes(): @@ -102,9 +92,6 @@ Node.__init__(self) OrderedContainer.__init__(self) - def isLeaf(self): - return False - def getChildNodes(self, iface=None, info=None): """Return the list of child nodes implementing the specified interface Override this method if the element is a virtual container. @@ -125,9 +112,6 @@ def __init__(self): Node.__init__(self) - def isLeaf(self): - return True - def getChildNodes(self, iface=None, info=None): """Return the list of child nodes implementing the specified interface """ Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/displays/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/elements/displays/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/elements/displays/__init__.py Thu Oct 20 14:31:33 2005 @@ -37,9 +37,6 @@ implements(IDisplay) - def __init__(self): - Element.__init__(self) - def __iter__(self): return iter([]) Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/displays/boxgroup.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/elements/displays/boxgroup.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/elements/displays/boxgroup.py Thu Oct 20 14:31:33 2005 @@ -40,11 +40,11 @@ >>> from cpsskins.elements.portlet import Portlet >>> portlet1, portlet2 = (Portlet('portlet1'), Portlet('portlet2')) - >>> portlet1._identifier = 1 - >>> portlet2._identifier = 2 + >>> portlet1.identifier = 1 + >>> portlet2.identifier = 2 >>> boxgroup = BoxGroup() - >>> boxgroup._identifier = 12345 + >>> boxgroup.identifier = 12345 >>> boxgroup <BoxGroup: 12345> @@ -78,12 +78,12 @@ self._order = PersistentList() def __repr__(self): - return "<BoxGroup: %s>" % self.getIdentifier() + return "<BoxGroup: %s>" % self.identifier def insert(self, order, item): """Insert an element at the specified 'order' position """ - self._order.insert(order, item.getIdentifier()) + self._order.insert(order, item.identifier) self._p_changed = True logger.log(DEBUG, "Inserted %s in %s at position %s" % (repr(item), repr(self), order) @@ -92,14 +92,14 @@ def remove(self, item): """Remove an element """ - self._order.remove(item.getIdentifier()) + self._order.remove(item.identifier) self._p_changed = True logger.log(DEBUG, "Removed %s from %s" % (repr(item), repr(self))) def append(self, item): """Add an element in the last position. """ - self._order.append(item.getIdentifier()) + self._order.append(item.identifier) self._p_changed = True logger.log(DEBUG, "Appended %s to %s" % (repr(item), repr(self))) @@ -107,10 +107,10 @@ return len(self._order) def index(self, item): - return self._order.index(item.getIdentifier()) + return self._order.index(item.identifier) def __contains__(self, item): - return item.getIdentifier() in self._order + return item.identifier in self._order def __iter__(self): return iter(self._order) Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/formats/style.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/elements/formats/style.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/elements/formats/style.py Thu Oct 20 14:31:33 2005 @@ -152,7 +152,7 @@ """Render a style in CSS >>> s = Style() - >>> s._identifier = '12345' + >>> s.identifier = '12345' >>> s['div.body'] = {'color': 'red'} >>> r = CSSRenderer(s) @@ -181,7 +181,7 @@ def __str__(self): """Return the style's class name""" - return 'style%s' % self.style.getIdentifier() + return 'style%s' % self.style.identifier def __call__(self): """Render the style in CSS""" Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/elements/interfaces.py Thu Oct 20 14:31:33 2005 @@ -22,7 +22,7 @@ from zope.app.container.interfaces import IContained from zope.app.container.interfaces import IOrderedContainer, IItemContainer from zope.i18nmessageid import MessageFactory -from zope.interface import Interface +from zope.interface import Interface, Attribute from zope.interface.interfaces import IInterface from zope.schema import TextLine @@ -31,17 +31,11 @@ # Elements class IElement(IAttributeAnnotatable): - elementtype = TextLine( - title=u'Element type', - required=False, - readonly=True, - ) + identifier = Attribute("Identifier") - contenttype = TextLine( - title=u'Content type', - required=False, - readonly=True, - ) + elementtype = Attribute("Element type") + + contenttype = Attribute("Content type") def __str__(): """The string representation is used as an identifier in a relation.""" @@ -49,23 +43,15 @@ def name(): """ """ + # this will go away def edit(k, v): """ """ - def getIdentifier(): - """Get the element's identifier.""" - - def setIdentifier(id): - """Set the element's identifier.""" - - def isIdenticalTo(other): + def getContentType(): """ """ def getElementType(): - """Return the element's type.""" - - def getContentType(): - """Return the element's content type.""" + """ """ class INode(IElement): @@ -76,9 +62,6 @@ class IInnerNode(INode, IOrderedContainer): - def isLeaf(): - """Return True is the element is a leaf.""" - def getChildNodes(iface, info): """Return the list of child nodes implementing the specified interface Override this method if the element is a virtual container. @@ -86,9 +69,6 @@ class ILeaf(INode): - def isLeaf(): - """Return True is the element is a leaf.""" - def getChildNodes(iface, info): """Return the list of child nodes implementing the specified interface Override this method if the element is a virtual container. @@ -211,12 +191,6 @@ title=_("Portlet's title"), required=False) - def getIdentifier(): - """ """ - - def __call__(info): - """Return the data to display.""" - class ISlot(ICanvas, IItemContainer): """A slot. """ Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/portlet.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/elements/portlet.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/elements/portlet.py Thu Oct 20 14:31:33 2005 @@ -39,7 +39,6 @@ implements(IPortlet) def __init__(self, title=''): - Leaf.__init__(self) self.title = title def __repr__(self): Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/slot.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/elements/slot.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/elements/slot.py Thu Oct 20 14:31:33 2005 @@ -20,7 +20,7 @@ from zope.interface import implements from cpsskins.elements import InnerNode -from cpsskins.elements.interfaces import ISlot, IPortlet +from cpsskins.elements.interfaces import ILeaf, ISlot, IPortlet from cpsskins.ontology import hasPortlet, hasPortletFromPerspective from cpsskins.relations.tool import RelationTool from cpsskins.storage.interfaces import IPortletStorage @@ -33,7 +33,7 @@ >>> slot Slot('Some slot', '') - >>> slot.isLeaf() + >>> ILeaf.providedBy(slot) False """ @@ -52,9 +52,6 @@ def __repr__(self): return "Slot('%s', '%s')" % (self.title, str(self)) - def isLeaf(self): - return False - def getChildNodes(self, iface=None, info=None): """Return the list of child nodes implementing the specified interface Override this method if the element is a virtual container. @@ -86,7 +83,7 @@ if a in display and b in display: index = display.index return cmp(index(a), index(b)) - return cmp(a.getIdentifier(), b.getIdentifier()) + return cmp(a.identifier, b.identifier) # sort the portlets portlets.sort(cmp_by_order) Modified: z3lab/cpsskins/branches/jmo-perspectives/engines/common/filters/effect/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/engines/common/filters/effect/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/engines/common/filters/effect/__init__.py Thu Oct 20 14:31:33 2005 @@ -66,7 +66,7 @@ tmutil = getThemeManager() cache = tmutil.getImageCache() key = { - 'portlet': element.getIdentifier(), + 'portlet': element.identifier, 'size': new_size, } Modified: z3lab/cpsskins/branches/jmo-perspectives/engines/common/filters/style/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/engines/common/filters/style/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/engines/common/filters/style/__init__.py Thu Oct 20 14:31:33 2005 @@ -41,8 +41,8 @@ >>> class FakeStyle: ... implements(IStyle) - ... def getIdentifier(self): - ... return '12345' + ... def __init__(self): + ... self.identifier = '12345' >>> from zope.app.testing import ztapi >>> from cpsskins.elements.formats.style import CSSRenderer @@ -50,7 +50,7 @@ >>> ztapi.provideAdapter(IStyle, ICSSRenderer, CSSRenderer) >>> s = FakeStyle() - >>> s.getIdentifier() + >>> s.identifier '12345' >>> f = StyleFilter(s, request) Modified: z3lab/cpsskins/branches/jmo-perspectives/engines/jsr168/filters/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/engines/jsr168/filters/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/engines/jsr168/filters/__init__.py Thu Oct 20 14:31:33 2005 @@ -48,7 +48,7 @@ if not ISlot.providedBy(getParent(element)): return data - id = element.getIdentifier() + id = element.identifier state = self.getState(id) markup = '<div class="box">' Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/__init__.py Thu Oct 20 14:31:33 2005 @@ -17,7 +17,10 @@ """ __docformat__ = "reStructuredText" + from zope.app.publisher.browser.menu import getMenu +from zope.component import adapts +from zope.interface import implements from zope.component.exceptions import ComponentLookupError from zope.schema import TextLine from zope.i18nmessageid import MessageFactory @@ -31,8 +34,8 @@ _ = MessageFactory("cpsskins") class IActionsPortlet(IPortlet): - """Interface for actions portlet""" - + """Interface for actions portlet. + """ category = TextLine( title=_("Category"), required=True) @@ -40,10 +43,17 @@ class ActionsPortlet(Portlet): """Actions portlet """ - def __init__(self, category='zmi_actions', **kw): + implements(IActionsPortlet) + + def __init__(self, title='', category='zmi_actions', **kw): + self.title = title self.category = category class ActionsPortletData(object): + """The actions portlet's display data + """ + adapts(IActionsPortlet, IContextInfo) + implements(IDisplayData) def __init__(self, portlet, info): try: Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/configure.zcml ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/configure.zcml (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/actions/configure.zcml Thu Oct 20 14:31:33 2005 @@ -1,4 +1,5 @@ <configure + xmlns="http://namespaces.zope.org/zope" xmlns:i18n="http://namespaces.zope.org/i18n" xmlns:cpsskins="http://namespaces.zope.org/cpsskins" i18n_domain="cpsskins" @@ -12,8 +13,11 @@ description="A portlet that displays actions" factory=".ActionsPortlet" schema=".IActionsPortlet" - data=".ActionsPortletData" icon="actions-icon.png" /> + <adapter + factory=".ActionsPortletData" + /> + </configure> Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/__init__.py Thu Oct 20 14:31:33 2005 @@ -17,7 +17,8 @@ """ __docformat__ = "reStructuredText" -from zope.component import getMultiAdapter +from zope.component import adapts, getMultiAdapter +from zope.interface import implements from zope.app.traversing.browser.interfaces import IAbsoluteURL from zope.i18nmessageid import MessageFactory @@ -34,16 +35,22 @@ class BreadcrumbsPortlet(Portlet): """Breadcrumbs portlet """ + implements(IBreadcrumbsPortlet) + + def __init__(self, title=''): + self.title = title class BreadcrumbsPortletData(object): + """The breadcrumbs portlet's display data + """ + adapts(IBreadcrumbsPortlet, IContextInfo) + implements(IDisplayData) def __init__(self, portlet, info): url = getMultiAdapter((info.location, info.request), IAbsoluteURL) items = [ - Item( - title=bc['name'], - url=bc['url'], - ) - for bc in url.breadcrumbs()] + Item(title=bc['name'], url=bc['url']) + for bc in url.breadcrumbs() + ] info.data = Items(items) Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/configure.zcml ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/configure.zcml (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/breadcrumbs/configure.zcml Thu Oct 20 14:31:33 2005 @@ -1,4 +1,5 @@ <configure + xmlns="http://namespaces.zope.org/zope" xmlns:cpsskins="http://namespaces.zope.org/cpsskins" xmlns:i18n="http://namespaces.zope.org/i18n" i18n_domain="cpsskins" @@ -12,8 +13,11 @@ description="A portlet that displays a navigation trail" factory=".BreadcrumbsPortlet" schema=".IBreadcrumbsPortlet" - data=".BreadcrumbsPortletData" icon="breadcrumbs-icon.png" /> + <adapter + factory=".BreadcrumbsPortletData" + /> + </configure> Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/__init__.py Thu Oct 20 14:31:33 2005 @@ -18,9 +18,11 @@ __docformat__ = "reStructuredText" from zope.app.container.contained import contained -from zope.documenttemplate.documenttemplate import html_quote from zope.app.zptpage.zptpage import ZPTPage from zope.app.dtmlpage.dtmlpage import DTMLPage +from zope.documenttemplate.documenttemplate import html_quote +from zope.component import adapts +from zope.interface import implements from ZODB.POSException import ConflictError from zope.i18nmessageid import MessageFactory from zope.schema import Choice, Text @@ -60,11 +62,18 @@ class CustomPortlet(Portlet): """Custom portlet """ - def __init__(self, format='', source=''): + implements(ICustomPortlet) + + def __init__(self, title='', format='', source=''): + self.title = title self.format = format self.source = source class CustomPortletData(object): + """The custom portlet's display data + """ + adapts(ICustomPortlet, IContextInfo) + implements(IDisplayData) def __init__(self, portlet, info): self.portlet = portlet @@ -78,14 +87,14 @@ if format in page_factories: page = page_factories[format]() page = contained(page, info.location) - page.setSource(self.source) - markup = renderPage(page, info.request) + page.setSource(portlet.source) + markup = _renderPage(page, info.request) else: markup = _("Page not configured.") return markup -def renderPage(page, request): +def _renderPage(page, request): markup = '' try: markup = page.render(request) Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/configure.zcml ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/configure.zcml (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/custom/configure.zcml Thu Oct 20 14:31:33 2005 @@ -1,4 +1,5 @@ <configure + xmlns="http://namespaces.zope.org/zope" xmlns:i18n="http://namespaces.zope.org/i18n" xmlns:cpsskins="http://namespaces.zope.org/cpsskins" i18n_domain="cpsskins" @@ -12,8 +13,11 @@ description="A portlet that displays a python, ZPT, DTML page" factory=".CustomPortlet" schema=".ICustomPortlet" - data=".CustomPortletData" icon="custom-icon.png" /> + <adapter + factory=".CustomPortletData" + /> + </configure> Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/__init__.py Thu Oct 20 14:31:33 2005 @@ -17,6 +17,8 @@ """ __docformat__ = "reStructuredText" +from zope.component import adapts +from zope.interface import implements from zope.schema import Text from zope.i18nmessageid import MessageFactory @@ -27,40 +29,31 @@ _ = MessageFactory("cpsskins") class IDummyPortlet(IPortlet): - """Interface for dummy portlet""" - + """Interface for dummy portlet. + """ text = Text( title=_("Dummy text"), required=True) class DummyPortlet(Portlet): """Dummy portlet - - >>> from zope.interface.verify import verifyClass - >>> verifyClass(IDummyPortlet, DummyPortlet) - True - - >>> from zope.app.testing import ztapi - >>> from cpsskins.thememanager import ThemeManagement - >>> thememanager = ThemeManagement() - >>> from cpsskins.interfaces import IThemeManagement - >>> ztapi.provideUtility(IThemeManagement, thememanager, name='themes') - - >>> portlet = DummyPortlet(text='text') - >>> portlet.text - 'text' - """ + implements(IDummyPortlet) - def __init__(self, text='', **kw): + def __init__(self, title='', text='', **kw): + self.title = title self.text = text class DummyPortletData(object): + """The dummy portlet's display data + """ + adapts(IDummyPortlet, IContextInfo) + implements(IDisplayData) def __init__(self, portlet, info): self.portlet = portlet self.info = info def __call__(self, **kw): - return self.portlet.text + return self.portlet.text or _("No text available") Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/configure.zcml ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/configure.zcml (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/dummy/configure.zcml Thu Oct 20 14:31:33 2005 @@ -1,4 +1,5 @@ <configure + xmlns="http://namespaces.zope.org/zope" xmlns:i18n="http://namespaces.zope.org/i18n" xmlns:cpsskins="http://namespaces.zope.org/cpsskins" i18n_domain="cpsskins" @@ -12,8 +13,11 @@ description="A portlet for testing" factory=".DummyPortlet" schema=".IDummyPortlet" - data=".DummyPortletData" icon="dummy-icon.png" /> + <adapter + factory=".DummyPortletData" + /> + </configure> Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/image/__init__.py Thu Oct 20 14:31:33 2005 @@ -20,6 +20,8 @@ from zope.app import zapi from zope.app.file.image import Image as ImageFile from zope.app.file.interfaces import IImage +from zope.component import adapts +from zope.interface import implements from zope.schema import TextLine, Bytes, BytesLine from zope.i18nmessageid import MessageFactory @@ -31,8 +33,8 @@ _ = MessageFactory("cpsskins") class IImagePortlet(IPortlet, IImage): - """Interface for the image portlet""" - + """Interface for the image portlet. + """ link = TextLine( title=_("A link"), required=False) @@ -56,12 +58,18 @@ class ImagePortlet(Portlet, ImageFile): """Image portlet """ + implements(IImagePortlet) - def __init__(self, link='', **kw): - ImageFile.__init__(self, **kw) + def __init__(self, title='', link='', **kw): + self.title = title self.link = '' + ImageFile.__init__(self, **kw) class ImagePortletData(object): + """The image portlet's display data + """ + adapts(IImagePortlet, IContextInfo) + implements(IDisplayData) def __init__(self, portlet, info): path = '' Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/image/configure.zcml ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/image/configure.zcml (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/image/configure.zcml Thu Oct 20 14:31:33 2005 @@ -1,4 +1,5 @@ <configure + xmlns="http://namespaces.zope.org/zope" xmlns:i18n="http://namespaces.zope.org/i18n" xmlns:cpsskins="http://namespaces.zope.org/cpsskins" i18n_domain="cpsskins" @@ -12,8 +13,11 @@ description="A portlet that displays an image" factory=".ImagePortlet" schema=".IImagePortlet" - data=".ImagePortletData" icon="image-icon.png" /> + <adapter + factory=".ImagePortletData" + /> + </configure> Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/__init__.py Thu Oct 20 14:31:33 2005 @@ -19,6 +19,8 @@ from zope.app import zapi from zope.app.publisher.browser import applySkin +from zope.component import adapts +from zope.interface import implements from zope.i18nmessageid import MessageFactory from zope.publisher.interfaces.browser import ILayer, IDefaultBrowserLayer from zope.publisher.interfaces.browser import IBrowserRequest @@ -38,13 +40,19 @@ class IMacroSlotPortlet(IPortlet): """Interface for the macro slot portlet""" - # XXX maybe make the slot's name configurable - class MacroSlotPortlet(Portlet): """Macro slot portlet """ + implements(IMacroSlotPortlet) + + def __init__(self, title=''): + self.title = title class MacroSlotPortletData(object): + """The macro slot's portlet's display data + """ + adapts(IMacroSlotPortlet, IContextInfo) + implements(IDisplayData) def __init__(self, portlet, info): self.portlet = portlet Modified: z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/configure.zcml ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/configure.zcml (original) +++ z3lab/cpsskins/branches/jmo-perspectives/portlets/macroslot/configure.zcml Thu Oct 20 14:31:33 2005 @@ -1,4 +1,5 @@ <configure + xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser" xmlns:i18n="http://namespaces.zope.org/i18n" xmlns:cpsskins="http://namespaces.zope.org/cpsskins" @@ -13,10 +14,13 @@ description="A portlet that displays the main content area of a page" factory=".MacroSlotPortlet" schema=".IMacroSlotPortlet" - data=".MacroSlotPortletData" icon="macroslot-icon.png" /> + <adapter + factory=".MacroSlotPortletData" + /> + <browser:page for=".IMacroSlotPortlet" name="macroSlotEditor" Modified: z3lab/cpsskins/branches/jmo-perspectives/thememanager.py ============================================================================== --- z3lab/cpsskins/branches/jmo-perspectives/thememanager.py (original) +++ z3lab/cpsskins/branches/jmo-perspectives/thememanager.py Thu Oct 20 14:31:33 2005 @@ -69,7 +69,7 @@ def registerElement(self, element): id = self.getIdRegistry().register(element) # store the element's id in the element itself. - element.setIdentifier(id) + element.identifier = id def unregisterElement(self, element): id = self.getIdRegistry().unregister(element) -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins