Author: jmorliaguet
Date: Mon Apr  3 22:54:39 2006
New Revision: 2776

Added:
   cpsskins/branches/jmo-perspectives/standard/ds/
   cpsskins/branches/jmo-perspectives/standard/ds/README.txt   (contents, props 
changed)
   cpsskins/branches/jmo-perspectives/standard/ds/__init__.py   (contents, 
props changed)
   cpsskins/branches/jmo-perspectives/standard/ds/configure.zcml   (contents, 
props changed)
   cpsskins/branches/jmo-perspectives/standard/ds/image.py   (contents, props 
changed)
   cpsskins/branches/jmo-perspectives/standard/ds/item.py   (contents, props 
changed)
   cpsskins/branches/jmo-perspectives/standard/ds/items.py   (contents, props 
changed)
   cpsskins/branches/jmo-perspectives/standard/ds/metadata.py   (contents, 
props changed)
   cpsskins/branches/jmo-perspectives/tests/test_ds.py
      - copied, changed from r2773, 
cpsskins/branches/jmo-perspectives/tests/test_model.py
Removed:
   cpsskins/branches/jmo-perspectives/model/
   cpsskins/branches/jmo-perspectives/tests/test_model.py
Modified:
   cpsskins/branches/jmo-perspectives/configure.zcml
   cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt
   cpsskins/branches/jmo-perspectives/standard/configure.zcml
   cpsskins/branches/jmo-perspectives/standard/filters/effect/__init__.py
   cpsskins/branches/jmo-perspectives/standard/portlets/actions/portlet.py
   cpsskins/branches/jmo-perspectives/standard/portlets/breadcrumbs/portlet.py
   cpsskins/branches/jmo-perspectives/standard/portlets/image/portlet.py
Log:

- moved the standard data structures from cpsskins.model to
  cpsskins.standard.ds



Modified: cpsskins/branches/jmo-perspectives/configure.zcml
==============================================================================
--- cpsskins/branches/jmo-perspectives/configure.zcml   (original)
+++ cpsskins/branches/jmo-perspectives/configure.zcml   Mon Apr  3 22:54:39 2006
@@ -82,8 +82,6 @@
 
   <include package=".portlets" />
 
-  <include package=".model" />
-
   <include package=".storage" />
 
   <include package=".standard" />

Modified: cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt
==============================================================================
--- cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt        
(original)
+++ cpsskins/branches/jmo-perspectives/doc/portlet-rendering.txt        Mon Apr 
 3 22:54:39 2006
@@ -39,9 +39,10 @@
 
    the actual content of the display data is either:
 
-   - a list of menu items (model.Items, model.Item)
+   - a list of menu items (items.Items, item.Item)
 
-    >>> from cpsskins.model import Item, Items
+    >>> from cpsskins.standard.ds.item import Item
+    >>> from cpsskins.standard.ds.items import Items
     >>> item = Item(title=u'Item title', url=u'@@url.html', icon=u'')
     >>> pprint(item())
     {'description': u'',
@@ -144,7 +145,7 @@
 
     a) frame box
     ------------
-    >>> from cpsskins.model import MetaData
+    >>> from cpsskins.standard.ds.metadata import MetaData
     >>> info.metadata = MetaData(title=u'Example frame box')
     >>> widget = Widget('frame_box')
     >>> test_render(widget, rendered, info)
@@ -184,7 +185,7 @@
 Widgets displaying images
 -------------------------
 
-    >>> from cpsskins.model import Image
+    >>> from cpsskins.standard.ds.image import Image
     >>> info.data = Image(path=u'/some/image.png')
 
     a) image

Modified: cpsskins/branches/jmo-perspectives/standard/configure.zcml
==============================================================================
--- cpsskins/branches/jmo-perspectives/standard/configure.zcml  (original)
+++ cpsskins/branches/jmo-perspectives/standard/configure.zcml  Mon Apr  3 
22:54:39 2006
@@ -35,4 +35,9 @@
 
   <include package=".io" />
 
+
+  <!-- Standard datastructures -->
+
+  <include package=".ds" />
+
 </configure>

Added: cpsskins/branches/jmo-perspectives/standard/ds/README.txt
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/ds/README.txt   Mon Apr  3 
22:54:39 2006
@@ -0,0 +1,15 @@
+
+$id:$
+
+This package contains the data structures used by content elements such as 
portlets
+to represent information.
+
+Available data structures are:
+
+- Metadata
+
+- Item
+
+- Items
+
+- Image

Added: cpsskins/branches/jmo-perspectives/standard/ds/__init__.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/ds/__init__.py  Mon Apr  3 
22:54:39 2006
@@ -0,0 +1,19 @@
+##############################################################################
+#
+# Copyright (c) 2005-2006 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"
+

Added: cpsskins/branches/jmo-perspectives/standard/ds/configure.zcml
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/ds/configure.zcml       Mon Apr 
 3 22:54:39 2006
@@ -0,0 +1,42 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope";>
+
+  <!-- to be moved to cpsskins.configuration -->
+
+  <class class=".metadata.MetaData">
+
+    <require
+        permission="zope.View"
+        interface=".metadata.IMetaData"
+        />
+
+  </class>
+
+  <class class=".item.Item">
+
+    <require
+        permission="zope.View"
+        interface=".item.IItem"
+        />
+
+  </class>
+
+  <class class=".items.Items">
+
+    <require
+        permission="zope.View"
+        interface=".items.IItems"
+        />
+
+  </class>
+
+  <class class=".image.Image">
+
+    <require
+        permission="zope.View"
+        interface=".image.IImage"
+        />
+
+  </class>
+
+</configure>

Added: cpsskins/branches/jmo-perspectives/standard/ds/image.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/ds/image.py     Mon Apr  3 
22:54:39 2006
@@ -0,0 +1,83 @@
+##############################################################################
+#
+# Copyright (c) 2005-2006 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 pprint import pprint
+
+from zope.interface import implements, Interface
+from zope.schema import TextLine
+
+class IImage(Interface):
+    """An image.
+    """
+    url = TextLine(
+        title=_(u"Image URL"),
+        description=_(u"The URL of the image."),
+        required=False,
+        )
+
+    path = TextLine(
+        title=_(u"Image path"),
+        description=_(u"The image's path."),
+        required=False,
+        )
+
+class Image(object):
+    """An image.
+
+    A path may be specified or a URL but not both.
+
+    >>> image = Image(path=u'Image.png')
+    >>> image()
+    {'url': u'', 'path': u'Image.png'}
+    >>> image.path
+    u'Image.png'
+
+    >>> image = Image(url=u'http://some.site/image.png')
+    >>> image()
+    {'url': u'http://some.site/image.png', 'path': u''}
+    >>> image.url
+    u'http://some.site/image.png'
+
+    >>> Image(path=u'Image.png', url=u'http://some.site/image.png')
+    Traceback (most recent call last):
+    ...
+    ValueError: Image: cannot specify both a path and a URL.
+
+    """
+    implements(IImage)
+
+    def __init__(self, path=u'', url=u''):
+        if path and url:
+            raise ValueError("Image: cannot specify both a path and a URL.")
+        self.path = path
+        self.url = url
+
+    def __repr__(self):
+        return "<Image at '%s'>" % self.path or self.link
+
+    def __call__(self):
+        return {
+            'path': self.path,
+            'url': self.url,
+            }
+
+    def __getitem__(self, key):
+        return getattr(self, key)
+
+

Added: cpsskins/branches/jmo-perspectives/standard/ds/item.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/ds/item.py      Mon Apr  3 
22:54:39 2006
@@ -0,0 +1,112 @@
+##############################################################################
+#
+# Copyright (c) 2005-2006 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 pprint import pprint
+
+from zope.interface import implements, Interface
+from zope.schema import TextLine, Bool
+
+class IItem(Interface):
+    """Item.
+    """
+    def __getitem__(k):
+        """Get the item"""
+
+    title = TextLine(
+        title=_(u"Item title"),
+        description=_(u"The title of the item."),
+        required=False,
+        )
+
+    description = TextLine(
+        title=_(u"Item description"),
+        description=_(u"A description of the item."),
+        required=False,
+        )
+
+    url = TextLine(
+        title=_(u"Item URL"),
+        description=_(u"The URL of the item."),
+        required=False,
+        )
+
+    selected = Bool(
+        title=_(u"Item selection state"),
+        description=_(u"True if the item is selected."),
+        required=False,
+        )
+
+    icon = TextLine(
+        title=_(u"Item icon"),
+        description=_(u"An icon of the item."),
+        required=False,
+        )
+
+
+
+class Item(object):
+    """Some item
+
+    >>> menuitem = Item(title=u'Item title',
+    ...    description=u'Item description',
+    ...    url=u'/@@itemurl.html')
+    ...    selected=True,
+    ...    icon=u'icon.png')
+
+    >>> pprint(menuitem())
+    {'description': u'Item description',
+     'icon': u'',
+     'selected': False,
+     'title': u'Item title',
+     'url': u'/@@itemurl.html'}
+
+    >>> menuitem['title']
+    u'Item title'
+
+    >>> menuitem['unknown']
+    Traceback (most recent call last):
+     ...
+    AttributeError: 'Item' object has no attribute 'unknown'
+
+    """
+    implements(IItem)
+
+    def __init__(self, title=u'', description=u'', url=u'', selected=False,
+                       icon=u''):
+        self.title = title
+        self.description = description
+        self.url = url
+        self.selected = selected
+        self.icon = icon
+
+    def __repr__(self):
+        return "<Item '%s'>" % self.title
+
+    def __call__(self):
+        return {
+            'title': self.title,
+            'description': self.description,
+            'url': self.url,
+            'selected': self.selected,
+            'icon': self.icon,
+            }
+
+    def __getitem__(self, key):
+        return getattr(self, key)
+

Added: cpsskins/branches/jmo-perspectives/standard/ds/items.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/ds/items.py     Mon Apr  3 
22:54:39 2006
@@ -0,0 +1,59 @@
+##############################################################################
+#
+# Copyright (c) 2005-2006 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 pprint import pprint
+
+from zope.interface import implements, Interface
+from zope.configuration.fields import Tokens
+
+class IItems(Interface):
+    """Menu items.
+    """
+    def __iter__():
+        """Iterates through items """
+
+    items = Tokens(
+        title=_(u"Items"),
+        description=_(u"An ordered collection of items"),
+        required=False,
+        )
+
+class Items(object):
+    """A list of menu items
+
+    >>> item = Item(title=u'item')
+    >>> items = Items([item])
+    >>> [i for i in items]
+    [<Item 'item'>]
+
+    """
+    implements(IItems)
+
+    def __init__(self, items=[]):
+        self.items = items
+
+    def __repr__(self):
+        return "<Items>"
+
+    def __call__(self):
+        return list(self.items)
+
+    def __iter__(self):
+        return iter(self.items)
+

Added: cpsskins/branches/jmo-perspectives/standard/ds/metadata.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/ds/metadata.py  Mon Apr  3 
22:54:39 2006
@@ -0,0 +1,69 @@
+##############################################################################
+#
+# Copyright (c) 2005-2006 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 pprint import pprint
+
+from zope.interface import implements, Interface
+from zope.schema import TextLine
+
+class IMetaData(Interface):
+    """Meta-data
+    """
+    title = TextLine(
+        title=_(u"Title"),
+        description=_(u"The title of the object."),
+        required=False,
+        )
+
+    description = TextLine(
+        title=_(u"Description"),
+        description=_(u"A description of the object."),
+        required=False,
+        )
+
+    url = TextLine(
+        title=_(u"URL"),
+        description=_(u"The URL of the object."),
+        required=False,
+        )
+
+class MetaData(object):
+    """Meta-data structure
+    """
+    implements(IMetaData)
+
+    def __init__(self, title=u'', description=u'', url=u''):
+        self.title = title
+        self.description = description
+        self.url = url
+
+    def __repr__(self):
+        return "<Metadata '%s'>"
+
+    def __call__(self):
+        return {
+            'title': self.title,
+            'description': self.description,
+            'url': self.url,
+            }
+
+    def __getitem__(self, key):
+        return getattr(self, key)
+
+

Modified: cpsskins/branches/jmo-perspectives/standard/filters/effect/__init__.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/standard/filters/effect/__init__.py      
(original)
+++ cpsskins/branches/jmo-perspectives/standard/filters/effect/__init__.py      
Mon Apr  3 22:54:39 2006
@@ -27,9 +27,9 @@
 from zope.schema.vocabulary import SimpleVocabulary
 from zope.security.proxy import removeSecurityProxy
 
-from cpsskins.model.interfaces import IImage
 from cpsskins.elements.interfaces import IDisplay
 from cpsskins.browser.rendering.interfaces import IFilterView
+from cpsskins.standard.ds.image import IImage
 from cpsskins.utils import getThemeManager
 
 logger = logging.getLogger("cpsskins")

Modified: 
cpsskins/branches/jmo-perspectives/standard/portlets/actions/portlet.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/standard/portlets/actions/portlet.py     
(original)
+++ cpsskins/branches/jmo-perspectives/standard/portlets/actions/portlet.py     
Mon Apr  3 22:54:39 2006
@@ -25,7 +25,8 @@
 
 from cpsskins import Portlet
 from cpsskins.interfaces import IPortlet
-from cpsskins.model import Items, Item
+from cpsskins.standard.ds.item import Item
+from cpsskins.standard.ds.items import Items
 
 _ = MessageFactory("cpsskins")
 

Modified: 
cpsskins/branches/jmo-perspectives/standard/portlets/breadcrumbs/portlet.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/standard/portlets/breadcrumbs/portlet.py 
(original)
+++ cpsskins/branches/jmo-perspectives/standard/portlets/breadcrumbs/portlet.py 
Mon Apr  3 22:54:39 2006
@@ -24,7 +24,8 @@
 
 from cpsskins import Portlet
 from cpsskins.interfaces import IPortlet
-from cpsskins.model import Items, Item
+from cpsskins.standard.ds.item import Item
+from cpsskins.standard.ds.items import Items
 
 _ = MessageFactory("cpsskins")
 

Modified: cpsskins/branches/jmo-perspectives/standard/portlets/image/portlet.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/standard/portlets/image/portlet.py       
(original)
+++ cpsskins/branches/jmo-perspectives/standard/portlets/image/portlet.py       
Mon Apr  3 22:54:39 2006
@@ -26,7 +26,7 @@
 
 from cpsskins import Portlet
 from cpsskins.interfaces import IPortlet
-from cpsskins.model import Image as ImageModel
+from cpsskins.standard.ds.image import Image as ImageModel
 
 _ = MessageFactory("cpsskins")
 

Copied: cpsskins/branches/jmo-perspectives/tests/test_ds.py (from r2773, 
cpsskins/branches/jmo-perspectives/tests/test_model.py)
==============================================================================
--- cpsskins/branches/jmo-perspectives/tests/test_model.py      (original)
+++ cpsskins/branches/jmo-perspectives/tests/test_ds.py Mon Apr  3 22:54:39 2006
@@ -23,7 +23,10 @@
 
 def test_suite():
     return unittest.TestSuite((
-        DocTestSuite('cpsskins.model'),
+        DocTestSuite('cpsskins.standard.ds.item'),
+        DocTestSuite('cpsskins.standard.ds.items'),
+        DocTestSuite('cpsskins.standard.ds.metadata'),
+        DocTestSuite('cpsskins.standard.ds.image'),
         ))
 
 if __name__ == '__main__':
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to