Author: jmorliaguet
Date: Mon May  1 16:47:38 2006
New Revision: 3006

Added:
   cpsskins/branches/paris-sprint-2006/configuration/storages/storage.py   
(contents, props changed)
Modified:
   cpsskins/branches/paris-sprint-2006/configuration/__init__.py
   cpsskins/branches/paris-sprint-2006/configuration/portlets/metaconfigure.py
   cpsskins/branches/paris-sprint-2006/configuration/storages/metaconfigure.py
   cpsskins/branches/paris-sprint-2006/configuration/storages/metadirectives.py
   cpsskins/branches/paris-sprint-2006/portlets/configure.zcml
   cpsskins/branches/paris-sprint-2006/relations/configure.zcml
   cpsskins/branches/paris-sprint-2006/setup/configure.zcml
   cpsskins/branches/paris-sprint-2006/standard/displays/configure.zcml
   cpsskins/branches/paris-sprint-2006/standard/formats/configure.zcml
   cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py
Log:

- more robust XML import, storages specify the type of item they contain.



Modified: cpsskins/branches/paris-sprint-2006/configuration/__init__.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/configuration/__init__.py       
(original)
+++ cpsskins/branches/paris-sprint-2006/configuration/__init__.py       Mon May 
 1 16:47:38 2006
@@ -21,8 +21,9 @@
 from cpsskins.configuration.engines.engine import IEngine, Engine
 from cpsskins.configuration.filters.filter import IFilter, Filter
 from cpsskins.configuration.fields.field import IField, Field
-from cpsskins.configuration.presentations.presentation import (
-    IPresentation, Presentation)
+from cpsskins.configuration.presentations.presentation import IPresentation
+from cpsskins.configuration.presentations.presentation import Presentation
 from cpsskins.configuration.renderers.renderer import IRenderer, Renderer
+from cpsskins.configuration.storages.storage import IStorage, Storage
 from cpsskins.configuration.widgets.widget import IWidget, Widget
 

Modified: 
cpsskins/branches/paris-sprint-2006/configuration/portlets/metaconfigure.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/configuration/portlets/metaconfigure.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/configuration/portlets/metaconfigure.py 
Mon May  1 16:47:38 2006
@@ -95,7 +95,7 @@
 
     # register the portlet factory
     utility(_context=_context, provides=IFactory, component=factory,
-            name=u'canvas-portlet-' + name)
+            name=u'portlet-' + name)
 
     # set up interface types
     alsoProvides(schema, IContentType)

Modified: 
cpsskins/branches/paris-sprint-2006/configuration/storages/metaconfigure.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/configuration/storages/metaconfigure.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/configuration/storages/metaconfigure.py 
Mon May  1 16:47:38 2006
@@ -17,14 +17,16 @@
 """
 __docformat__ = "reStructuredText"
 
+from zope.component.zcml import utility
 from zope.app.component.contentdirective import ClassDirective
 from zope.app.container.interfaces import IReadContainer, IWriteContainer
 from zope.configuration.exceptions import ConfigurationError
 
+from cpsskins import configuration
 from cpsskins.storage.interfaces import IStorage
 
 def storage(_context, id=None, title=None, description=None, class_=None,
-           interface=None):
+           interface=None, contains=None):
 
     if not id:
         raise ConfigurationError("Must specify a storage id.")
@@ -36,7 +38,10 @@
         raise ConfigurationError("Must specify a storage description.")
 
     if not class_:
-        raise ConfigurationError("Must specify a storage content class.")
+        raise ConfigurationError("Must specify a storage class.")
+
+    if not contains:
+        raise ConfigurationError("Must specify the interface of stored items.")
 
     if not interface:
         interface = IStorage
@@ -44,9 +49,10 @@
     # zope:content
     c = ClassDirective(_context=_context, class_=class_)
     c.factory(_context=_context, title=title, description=description) 
-    c.allow(_context=_context,
-        interface=(IReadContainer, interface))
-    c.require(_context=_context,
-        permission="zope.ManageSite",
-        set_schema=(IWriteContainer, interface))
-
+    c.allow(_context=_context, interface=(IReadContainer, interface))
+    c.require(_context=_context, permission="zope.ManageSite",
+              set_schema=(IWriteContainer, interface))
+
+    # set the type of object contained in the storage
+    utility(_context=_context, provides=configuration.IStorage,
+            component=configuration.Storage(contains), name=id)

Modified: 
cpsskins/branches/paris-sprint-2006/configuration/storages/metadirectives.py
==============================================================================
--- 
cpsskins/branches/paris-sprint-2006/configuration/storages/metadirectives.py    
    (original)
+++ 
cpsskins/branches/paris-sprint-2006/configuration/storages/metadirectives.py    
    Mon May  1 16:47:38 2006
@@ -57,3 +57,9 @@
         description=_(u"The storage interface (optional)"),
         required=False,
         )
+
+    contains = GlobalObject(
+        title=_(u"Item type."),
+        description=_(u"The type of item contained in the storage."),
+        required=False,
+        )

Added: cpsskins/branches/paris-sprint-2006/configuration/storages/storage.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/paris-sprint-2006/configuration/storages/storage.py       
Mon May  1 16:47:38 2006
@@ -0,0 +1,34 @@
+##############################################################################
+#
+# 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 zope.interface import implements, Interface, Attribute
+
+class IStorage(Interface):
+    """Storage configuration interface"""
+
+    itemtype = Attribute(u"Stored item types.")
+
+class Storage(object):
+    """A storage configuration
+    """
+    implements(IStorage)
+
+    def __init__(self, itemtype=None):
+        self.itemtype =itemtype
+

Modified: cpsskins/branches/paris-sprint-2006/portlets/configure.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/portlets/configure.zcml (original)
+++ cpsskins/branches/paris-sprint-2006/portlets/configure.zcml Mon May  1 
16:47:38 2006
@@ -15,6 +15,7 @@
       title="Portlet storage"
       description="A portlet storage contains local portlets"
       class="cpsskins.portlets.storage.PortletStorage"
+      contains="cpsskins.elements.interfaces.IPortlet"
   />
 
 

Modified: cpsskins/branches/paris-sprint-2006/relations/configure.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/relations/configure.zcml        
(original)
+++ cpsskins/branches/paris-sprint-2006/relations/configure.zcml        Mon May 
 1 16:47:38 2006
@@ -109,6 +109,7 @@
       description="A relation storage contains relations between objects"
       class="cpsskins.relations.storage.RelationStorage"
       interface="cpsskins.relations.interfaces.IRelationStorage"
+      contains="cpsskins.relations.interfaces.IRelation"
   />
 
   <!-- Relation tool -->

Modified: cpsskins/branches/paris-sprint-2006/setup/configure.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/configure.zcml    (original)
+++ cpsskins/branches/paris-sprint-2006/setup/configure.zcml    Mon May  1 
16:47:38 2006
@@ -60,6 +60,7 @@
       description="A snapshot storage contains site snapshots"
       class="cpsskins.setup.storage.SnapshotStorage"
       interface="cpsskins.setup.storage.ISnapshotStorage"
+      contains="cpsskins.setup.snapshot.ISnapshot"
   />
 
 

Modified: cpsskins/branches/paris-sprint-2006/standard/displays/configure.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/displays/configure.zcml        
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/displays/configure.zcml        
Mon May  1 16:47:38 2006
@@ -11,6 +11,7 @@
       title="Display storage"
       description="A display storage"
       class=".storage.DisplayStorage"
+      contains="cpsskins.elements.interfaces.IDisplay"
   />
 
   <!-- Area display -->

Modified: cpsskins/branches/paris-sprint-2006/standard/formats/configure.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/formats/configure.zcml 
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/formats/configure.zcml Mon May 
 1 16:47:38 2006
@@ -9,6 +9,7 @@
       title="Format storage"
       description="A format storage"
       class=".storage.FormatStorage"
+      contains="cpsskins.elements.interfaces.IFormat"
   />
 
   <!-- Layout -->

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py Mon May 
 1 16:47:38 2006
@@ -26,12 +26,13 @@
 from zope.component import createObject
 
 from cpsskins import minjson as json
+from cpsskins import configuration
 from cpsskins.setup.interfaces import ISetting, IGlobalSetting, IDOMAdapter
 from cpsskins.setup.interfaces import IType
 from cpsskins.setup.interfaces import IResourceType, IResourceManager, 
IResource
 from cpsskins.setup.registration import reloadSetting, refreshSettings
 from cpsskins.setup.settings import ISettings
-from cpsskins.setup.utils import TarArchive
+from cpsskins.setup.utils import TarArchive, getTypeName
 from cpsskins.setup.snapshot import Snapshot
 from cpsskins.utils import getThemeManager
 
@@ -273,11 +274,16 @@
 
         uri_mapping = {}
 
+        storage_configuration = getUtility(configuration.IStorage, name)
+        itemtype = storage_configuration.itemtype
+
         for el in root.childNodes:
             if el.nodeType != Node.ELEMENT_NODE:
                 continue
-            factory_name = '%s-%s' % (name, el.tagName)
-            obj = createObject(factory-name)
+            content_typename = el.getAttribute('type') or el.tagName
+            resource_typename = getTypeName(itemtype)
+            factory_name = '%s-%s' % (resource_typename, content_typename)
+            obj = createObject(factory_name)
 
             importer = getMultiAdapter((obj, el), IDOMAdapter)
             importer.setDocument(document)
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to