Author: jmorliaguet
Date: Sun Oct 30 13:40:02 2005
New Revision: 28818

Added:
   z3lab/cpsskins/branches/jmo-perspectives/storage/interfaces.py   (contents, 
props changed)
   z3lab/cpsskins/branches/jmo-perspectives/storage/resources.py   (contents, 
props changed)
   z3lab/cpsskins/branches/jmo-perspectives/storage/storage.py   (contents, 
props changed)
Modified:
   z3lab/cpsskins/branches/jmo-perspectives/interfaces.py
   z3lab/cpsskins/branches/jmo-perspectives/storage/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/storage/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/storage/displays.py
   z3lab/cpsskins/branches/jmo-perspectives/storage/formats.py
   z3lab/cpsskins/branches/jmo-perspectives/storage/perspectives.py
   z3lab/cpsskins/branches/jmo-perspectives/storage/portlets.py
   z3lab/cpsskins/branches/jmo-perspectives/storage/relations.py
Log:

- added a resource storage

- some code cleanup / easier imports



Modified: z3lab/cpsskins/branches/jmo-perspectives/interfaces.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/interfaces.py      (original)
+++ z3lab/cpsskins/branches/jmo-perspectives/interfaces.py      Sun Oct 30 
13:40:02 2005
@@ -21,7 +21,8 @@
 from zope.app.cache.interfaces.ram import IRAMCache
 from zope.i18nmessageid import MessageFactory
 
-from cpsskins.elements.interfaces import IPortlet
+from cpsskins.elements.interfaces import IPortlet, IDisplay, IFormat
+from cpsskins.perspectives.interfaces import IPerspective
 
 _ = MessageFactory("cpsskins")
 

Modified: z3lab/cpsskins/branches/jmo-perspectives/storage/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/storage/__init__.py        
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/storage/__init__.py        Sun Oct 
30 13:40:02 2005
@@ -17,59 +17,3 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.app import zapi
-from zope.app.container.btree import BTreeContainer
-from zope.app.container.contained import Contained
-from zope.app.container.contained import ObjectAddedEvent, ObjectRemovedEvent
-from zope.app.container.interfaces import INameChooser
-from zope.app.event.objectevent import ObjectCopiedEvent
-from zope.app.location.pickling import locationCopy
-from zope.event import notify
-from zope.interface import implements
-
-from cpsskins.elements.interfaces import IElement
-from interfaces import IStorage
-
-class Storage(BTreeContainer, Contained):
-    """A base storage class"""
-
-    implements(IStorage)
-
-    def add(self, object, name=''):
-        """Add an object to the storage.
-        """
-        chooser = INameChooser(self)
-        name = chooser.chooseName(name, object)
-        self[name] = object
-        notify(ObjectAddedEvent(object))
-        return self[name]
-
-    def remove(self, objects):
-        """Remove an object from the storage.
-        """
-        if not isinstance(objects, (list, tuple)):
-            objects = [objects]
-        for obj in objects:
-            if IElement.providedBy(obj):
-                obj = zapi.name(obj)
-            if obj not in self:
-                raise KeyError("%s not in the storage." % obj)
-            del self[obj]
-
-    def duplicate(self, object):
-        """Duplicate an object in the storage.
-
-        Return the object of the duplication.
-        """
-        name = zapi.name(object)
-        if name not in self:
-            raise KeyError("%s not in the storage." % object)
-
-        chooser = INameChooser(self)
-        copy = locationCopy(object)
-        new_name = chooser.chooseName(name, copy)
-
-        notify(ObjectCopiedEvent(copy))
-        self[new_name] = copy
-
-        return self[new_name]

Modified: z3lab/cpsskins/branches/jmo-perspectives/storage/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/storage/configure.zcml     
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/storage/configure.zcml     Sun Oct 
30 13:40:02 2005
@@ -16,6 +16,14 @@
       interface=".interfaces.IRelationStorage"
   />
 
+  <!-- Resource storage -->
+
+  <cpsskins:storage
+      id="resources"
+      title="Resource storage"
+      description="A resource storage contains resources (images, ...)"
+      factory=".resources.ResourceStorage"
+  />
 
   <!-- Portlet storage -->
 

Modified: z3lab/cpsskins/branches/jmo-perspectives/storage/displays.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/storage/displays.py        
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/storage/displays.py        Sun Oct 
30 13:40:02 2005
@@ -17,10 +17,16 @@
 """
 __docformat__ = "reStructuredText"
 
+from zope.app.container.constraints import contains
 from zope.interface import implements
 
-from cpsskins.storage import Storage
-from interfaces import IDisplayStorage
+from cpsskins.interfaces import IDisplay
+from storage import Storage
+from interfaces import IStorage
+
+class IDisplayStorage(IStorage):
+
+    contains(IDisplay)
 
 class DisplayStorage(Storage):
     """A BTree-based display container"""

Modified: z3lab/cpsskins/branches/jmo-perspectives/storage/formats.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/storage/formats.py (original)
+++ z3lab/cpsskins/branches/jmo-perspectives/storage/formats.py Sun Oct 30 
13:40:02 2005
@@ -17,10 +17,16 @@
 """
 __docformat__ = "reStructuredText"
 
+from zope.app.container.constraints import contains
 from zope.interface import implements
 
-from cpsskins.storage import Storage
-from interfaces import IFormatStorage
+from cpsskins.interfaces import IFormat
+from storage import Storage
+from interfaces import IStorage
+
+class IFormatStorage(IStorage):
+
+    contains(IFormat)
 
 class FormatStorage(Storage):
     """A BTree-based display container"""

Added: z3lab/cpsskins/branches/jmo-perspectives/storage/interfaces.py
==============================================================================
--- (empty file)
+++ z3lab/cpsskins/branches/jmo-perspectives/storage/interfaces.py      Sun Oct 
30 13:40:02 2005
@@ -0,0 +1,27 @@
+##############################################################################
+#
+# 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 storage import IStorage
+
+from displays import IDisplayStorage
+from formats import IFormatStorage
+from relations import IRelationStorage
+from perspectives import IPerspectiveStorage
+from portlets import IPortletStorage
+from resources import IResourceStorage

Modified: z3lab/cpsskins/branches/jmo-perspectives/storage/perspectives.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/storage/perspectives.py    
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/storage/perspectives.py    Sun Oct 
30 13:40:02 2005
@@ -17,10 +17,16 @@
 """
 __docformat__ = "reStructuredText"
 
+from zope.app.container.constraints import contains
 from zope.interface import implements
 
-from cpsskins.storage import Storage
-from interfaces import IPerspectiveStorage
+from cpsskins.interfaces import IPerspective
+from storage import Storage
+from interfaces import IStorage
+
+class IPerspectiveStorage(IStorage):
+
+    contains(IPerspective)
 
 class PerspectiveStorage(Storage):
     """A BTree-based perspective container"""

Modified: z3lab/cpsskins/branches/jmo-perspectives/storage/portlets.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/storage/portlets.py        
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/storage/portlets.py        Sun Oct 
30 13:40:02 2005
@@ -17,10 +17,16 @@
 """
 __docformat__ = "reStructuredText"
 
+from zope.app.container.constraints import contains
 from zope.interface import implements
 
-from cpsskins.storage import Storage
-from interfaces import IPortletStorage
+from cpsskins.interfaces import IPortlet
+from storage import Storage
+from interfaces import IStorage
+
+class IPortletStorage(IStorage):
+
+    contains(IPortlet)
 
 class PortletStorage(Storage):
     """A BTree-based display container"""

Modified: z3lab/cpsskins/branches/jmo-perspectives/storage/relations.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/storage/relations.py       
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/storage/relations.py       Sun Oct 
30 13:40:02 2005
@@ -23,6 +23,7 @@
 
 from zope.app import zapi
 from zope.app.container.btree import BTreeContainer
+from zope.app.container.constraints import contains
 from zope.app.container.interfaces import INameChooser
 from zope.app.location.traversing import LocationPhysicallyLocatable
 from zope.interface import implements
@@ -31,8 +32,8 @@
 
 from cpsskins.relations import Predicate, CompoundPredicate
 from cpsskins.relations.interfaces import IRelation, IRelatable
-from cpsskins.storage import Storage
-from interfaces import IRelationStorage
+from storage import Storage
+from interfaces import IStorage
 
 import logging
 
@@ -55,11 +56,35 @@
        ),
     }
 
+class IRelationStorage(IStorage):
+
+    contains(IRelation)
+
+    def search(predicate, first, second, third):
+        """ """
+
+    def list():
+        """ """
+
+    def clear():
+        """ """
+
+    def getFirsts():
+        """ """
+
+    def getSeconds():
+        """ """
+
+    def getThirds():
+        """ """
+
+    def __delitem__(item):
+        """ """
+
 class RelationStorage(Storage):
     """A BTree-based relation container with a relation indexer.
 
     >>> from zope.interface.verify import verifyClass
-    >>> from interfaces import IRelationStorage
     >>> verifyClass(IRelationStorage, RelationStorage)
     True
 

Added: z3lab/cpsskins/branches/jmo-perspectives/storage/resources.py
==============================================================================
--- (empty file)
+++ z3lab/cpsskins/branches/jmo-perspectives/storage/resources.py       Sun Oct 
30 13:40:02 2005
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# 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.app.container.constraints import contains
+from zope.interface import implements
+
+from storage import Storage
+from interfaces import IStorage
+
+class IResourceStorage(IStorage):
+    """Interface for resource storages."""
+
+class ResourceStorage(Storage):
+    """A BTree-based resource container"""
+
+    implements(IResourceStorage)
+

Added: z3lab/cpsskins/branches/jmo-perspectives/storage/storage.py
==============================================================================
--- (empty file)
+++ z3lab/cpsskins/branches/jmo-perspectives/storage/storage.py Sun Oct 30 
13:40:02 2005
@@ -0,0 +1,90 @@
+##############################################################################
+#
+# 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.app import zapi
+from zope.app.container.btree import BTreeContainer
+from zope.app.container.contained import Contained
+from zope.app.container.contained import ObjectAddedEvent, ObjectRemovedEvent
+from zope.app.container.constraints import contains
+from zope.app.container.interfaces import INameChooser
+from zope.app.event.objectevent import ObjectCopiedEvent
+from zope.app.location.pickling import locationCopy
+from zope.event import notify
+from zope.interface import implements, Interface
+
+from cpsskins.elements.interfaces import IElement
+
+class IStorage(Interface):
+
+    def add(object):
+        """Add an object to the storage. Return the added object."""
+
+    def remove(objects):
+        """Remove an object from the storage."""
+
+    def duplicate(object):
+        """Duplicated an object in the storage.
+        Return the object of the duplication."""
+
+    def __setitem__(item):
+        """ """
+
+class Storage(BTreeContainer, Contained):
+    """A base storage class"""
+
+    implements(IStorage)
+
+    def add(self, object, name=''):
+        """Add an object to the storage.
+        """
+        chooser = INameChooser(self)
+        name = chooser.chooseName(name, object)
+        self[name] = object
+        notify(ObjectAddedEvent(object))
+        return self[name]
+
+    def remove(self, objects):
+        """Remove an object from the storage.
+        """
+        if not isinstance(objects, (list, tuple)):
+            objects = [objects]
+        for obj in objects:
+            if IElement.providedBy(obj):
+                obj = zapi.name(obj)
+            if obj not in self:
+                raise KeyError("%s not in the storage." % obj)
+            del self[obj]
+
+    def duplicate(self, object):
+        """Duplicate an object in the storage.
+
+        Return the object of the duplication.
+        """
+        name = zapi.name(object)
+        if name not in self:
+            raise KeyError("%s not in the storage." % object)
+
+        chooser = INameChooser(self)
+        copy = locationCopy(object)
+        new_name = chooser.chooseName(name, copy)
+
+        notify(ObjectCopiedEvent(copy))
+        self[new_name] = copy
+
+        return self[new_name]
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to