Author: jmorliaguet
Date: Sat Jun 17 14:25:36 2006
New Revision: 3431

Modified:
   cpsskins/branches/paris-sprint-2006/browser/tree/slot.py
   cpsskins/branches/paris-sprint-2006/doc/portlets.txt
   cpsskins/branches/paris-sprint-2006/elements/configure.zcml
   cpsskins/branches/paris-sprint-2006/elements/interfaces.py
   cpsskins/branches/paris-sprint-2006/elements/slot.py
   cpsskins/branches/paris-sprint-2006/standard/formats/widget.py

Log:

- added a vocabulary for listing available perspective choices



Modified: cpsskins/branches/paris-sprint-2006/browser/tree/slot.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/browser/tree/slot.py    (original)
+++ cpsskins/branches/paris-sprint-2006/browser/tree/slot.py    Sat Jun 17 
14:25:36 2006
@@ -51,7 +51,9 @@
         # The slot can override the perspective from which portlets are looked
         # up unless the assigned perspective is '.'
         slot_perspective = context.perspective
-        if slot_perspective != u'.':
+        if slot_perspective == u'':
+            perspective = None
+        elif slot_perspective != u'.':
             perspective = slot_perspective
 
         if perspective is None:
@@ -84,7 +86,9 @@
             raise TypeError("Only portlet can be added into slots")
 
         slot_perspective = container.perspective
-        if slot_perspective != u'*':
+        if slot_perspective == u'':
+            perspective = None
+        elif slot_perspective != u'.':
             perspective = slot_perspective
         else:
             perspective = getMultiAdapter((container, request), INegotiation,
@@ -168,11 +172,8 @@
         if not IPortlet.providedBy(content):
             raise TypeError("Only portlets can be removed from slots")
 
-        perspective = getMultiAdapter(
-            objects=(container, request),
-            interface=INegotiation,
-            name='negotiation',
-            ).getPerspective()
+        perspective = getMultiAdapter((container, request), INegotiation,
+                                      name='negotiation').getPerspective()
 
         portlets = getThemeManager(container).getPortletStorage()
 

Modified: cpsskins/branches/paris-sprint-2006/doc/portlets.txt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/doc/portlets.txt        (original)
+++ cpsskins/branches/paris-sprint-2006/doc/portlets.txt        Sat Jun 17 
14:25:36 2006
@@ -585,10 +585,10 @@
     >>> traversing_C.getChildNodes(u'some other perspective')
     [Portlet('6')]
 
-if the slot's assigned perspective is None then perspectives are ignored and
-portlets are added and looked from no specific perspective:
+if the slot's assigned perspective is an empty string then perspectives are
+ignored and portlets are added and looked up from no specific perspective:
 
-    >>> slot_C.perspective = None
+    >>> slot_C.perspective = u''
     >>> portlet7 = Portlet(u'7')
     >>> added = adding_C.add(portlet7)
 

Modified: cpsskins/branches/paris-sprint-2006/elements/configure.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/elements/configure.zcml (original)
+++ cpsskins/branches/paris-sprint-2006/elements/configure.zcml Sat Jun 17 
14:25:36 2006
@@ -280,6 +280,12 @@
       factory=".slot.Relatable"
   />
 
+  <utility
+     provides="zope.schema.interfaces.IVocabularyFactory"
+     component=".slot.PerspectivesVocabulary"
+     name="Slot perspectives"
+  />
+
   <interface
       interface=".interfaces.ISlot"
       type="cpsskins.setup.interfaces.IResourceType"

Modified: cpsskins/branches/paris-sprint-2006/elements/interfaces.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/elements/interfaces.py  (original)
+++ cpsskins/branches/paris-sprint-2006/elements/interfaces.py  Sat Jun 17 
14:25:36 2006
@@ -25,7 +25,7 @@
 from zope.i18nmessageid import MessageFactory
 from zope.interface import Interface, Attribute
 from zope.interface.interfaces import IInterface
-from zope.schema import TextLine
+from zope.schema import TextLine, List, Choice
 
 _ = MessageFactory("cpsskins")
 
@@ -141,9 +141,10 @@
             "inside a theme. Slot names must be unique on a same page."),
         required=True)
 
-    perspective = TextLine(
+    perspective = Choice(
         title=_(u"Perspective"),
-        description=_(u"The perspective used to look up portlets"),
+        description=_(u"The perspective used to add and look up portlets"),
+        vocabulary='Slot perspectives',
         required=False)
 
     def __str__():

Modified: cpsskins/branches/paris-sprint-2006/elements/slot.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/elements/slot.py        (original)
+++ cpsskins/branches/paris-sprint-2006/elements/slot.py        Sat Jun 17 
14:25:36 2006
@@ -17,14 +17,17 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.interface import implements
+from zope.interface import implements, alsoProvides
 from zope.component import adapts, getUtility
 from zope.component.factory import Factory
+from zope.schema.interfaces import IVocabularyFactory
+from zope.schema.vocabulary import SimpleVocabulary
 
 from cpsskins.elements.element import InnerNode
 from cpsskins.elements.interfaces import ISlot
 from cpsskins.relations.interfaces import IRelatable
 from cpsskins.storage.portlets import IPortletStorage
+from cpsskins.utils import getThemeManager
 
 class Slot(InnerNode):
     """Slot
@@ -40,7 +43,7 @@
     """
     implements(ISlot)
 
-    def __init__(self, name=u'', title=u'', description=u'', perspective=None):
+    def __init__(self, name=u'', title=u'', description=u'', perspective=u''):
         super(Slot, self).__init__()
         self.name = name
         self.title = title
@@ -88,7 +91,6 @@
         """
         return str(self.element)
 
-
 class Sublocations(object):
     """Get the sublocations of the slot
 
@@ -102,3 +104,16 @@
         yield None
 
 SlotFactory = Factory(Slot)
+
+def PerspectivesVocabulary(context):
+    """A vocabulary that contains the list of perspective choices
+    """
+    tmutil = getThemeManager(context)
+    perspectives = [(_(u'Ignore perspectives'), u''),
+                    (_(u'Use the current perspective'), u'.')]
+    for name, title in tmutil.listPerspectives():
+        perspectives.append((_(title), name))
+
+    return SimpleVocabulary.fromItems(perspectives)
+
+alsoProvides(PerspectivesVocabulary, IVocabularyFactory)

Modified: cpsskins/branches/paris-sprint-2006/standard/formats/widget.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/formats/widget.py      
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/formats/widget.py      Sat Jun 
17 14:25:36 2006
@@ -18,13 +18,12 @@
 __docformat__ = "reStructuredText"
 
 from persistent import Persistent
-from zope.schema.interfaces import IVocabularyFactory
-
 from zope.component import getUtilitiesFor
 from zope.interface import implements, alsoProvides
 from zope.i18nmessageid import MessageFactory
-from zope.schema.vocabulary import SimpleVocabulary
 from zope.schema import List, Choice
+from zope.schema.interfaces import IVocabularyFactory
+from zope.schema.vocabulary import SimpleVocabulary
 
 from cpsskins import configuration
 from cpsskins.elements.format import Format
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to