Author: jmorliaguet Date: Mon Oct 17 21:02:36 2005 New Revision: 28369 Added: z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/configure.zcml (contents, props changed) z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/ z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/README.txt (contents, props changed) z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/__init__.py (contents, props changed) z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/actions-icon.png (contents, props changed) z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/actions.py (contents, props changed) z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/configure.zcml (contents, props changed) Modified: z3lab/z3ecm/trunk/src/ecm/cpsskins/README.txt Log:
- new portlet (actions portlet) Modified: z3lab/z3ecm/trunk/src/ecm/cpsskins/README.txt ============================================================================== --- z3lab/z3ecm/trunk/src/ecm/cpsskins/README.txt (original) +++ z3lab/z3ecm/trunk/src/ecm/cpsskins/README.txt Mon Oct 17 21:02:36 2005 @@ -107,12 +107,22 @@ * example3/ -This example explains how to write a portlet that returns a list of items. +This example explains how to write a portlet that generate a list of items. This portlet does not generate any markup. The list of items will be rendered using a widget. +* example4/ + +This example explains how to write a portlet that generate a dynamic list of +items consisting of actions with a title and a url. + +The name of the category of actions is part of the portlet configuration. + +This portlet does not generate any markup. The list of items will be rendered +using a widget. + B) How to write a widget Added: z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/configure.zcml ============================================================================== --- (empty file) +++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example1/configure.zcml Mon Oct 17 21:02:36 2005 @@ -0,0 +1,18 @@ +<configure + xmlns:i18n="http://namespaces.zope.org/i18n" + xmlns:cpsskins="http://namespaces.zope.org/cpsskins" + i18n_domain="cpsskins" + > + + <!-- The 'Hello portlet' says 'Hello world' --> + + <cpsskins:portlet + name="hello" + title="Hello portlet" + description="A hello world" + factory=".hello.HelloPortlet" + schema=".hello.IHelloPortlet" + icon="hello-icon.png" + /> + +</configure> Added: z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/README.txt ============================================================================== --- (empty file) +++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/README.txt Mon Oct 17 21:02:36 2005 @@ -0,0 +1,5 @@ + +This portlet returns a list of actions items that can be displayed using a +widget. + +The user can select the category of actions to display. Added: z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/__init__.py ============================================================================== --- (empty file) +++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/__init__.py Mon Oct 17 21:02:36 2005 @@ -0,0 +1 @@ +# This is a package Added: z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/actions-icon.png ============================================================================== Binary file. No diff available. Added: z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/actions.py ============================================================================== --- (empty file) +++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/actions.py Mon Oct 17 21:02:36 2005 @@ -0,0 +1,71 @@ +############################################################################## +# +# Copyright (c) 2005 Nuxeo and Contributors. +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# +############################################################################## +""" + +$Id$ +""" +__docformat__ = "reStructuredText" + +from zope.component import adapts +from zope.interface import implements +from zope.schema import TextLine + +from cpsskins.browser.rendering.interfaces import IContextInfo, IDisplayData +from cpsskins.elements.interfaces import IPortlet +from cpsskins.elements.portlet import Portlet +from cpsskins.model import Items, Item + +class IActionsPortlet(IPortlet): + """Interface for the actions portlet""" + + category = TextLine( + title=u"Category", + ) + +class ActionsPortlet(Portlet): + """The actions portlet returns a list of items. + + """ + implements(IActionsPortlet) + + def __init__(self, category='zmi_actions', **kw): + Portlet.__init__(self, **kw) + self.category = category + +class ActionsDisplayData(object): + """The portlet creates a list of action items. + + The list of items can be used by some widget to produce HTML. + """ + adapts(IActionsPortlet, IContextInfo) + implements(IDisplayData) + + def __init__(self, portlet, info): + self.portlet = portlet + self.info = info + + try: + menu = getMenu(portlet.category, info.location, info.request) + except ComponentLookupError: + items = [] + else: + items = [ + Item( + title=ac['title'], + url=ac['action'], + icon=ac['icon'], + ) + for ac in menu] + + info.data = items Added: z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/configure.zcml ============================================================================== --- (empty file) +++ z3lab/z3ecm/trunk/src/ecm/cpsskins/example4/configure.zcml Mon Oct 17 21:02:36 2005 @@ -0,0 +1,18 @@ +<configure + xmlns:i18n="http://namespaces.zope.org/i18n" + xmlns:cpsskins="http://namespaces.zope.org/cpsskins" + i18n_domain="cpsskins" + > + + <!-- The 'Actions portlet' produces a list of actions items --> + + <cpsskins:portlet + name="actions" + title="Actions portlet" + description="A portlet that returns a list of actions items" + factory=".actions.ActionsPortlet" + schema=".actions.IActionsPortlet" + icon="actions-icon.png" + /> + +</configure> -- http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins