Author: jmorliaguet
Date: Sat May 13 22:28:54 2006
New Revision: 3125

Modified:
   cpsskins/branches/paris-sprint-2006/setup/interfaces.py
   cpsskins/branches/paris-sprint-2006/setup/io/utils.py
   cpsskins/branches/paris-sprint-2006/setup/manager.py
   cpsskins/branches/paris-sprint-2006/standard/io/setting.py
   cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py

Log:

- fixed the import of settings



Modified: cpsskins/branches/paris-sprint-2006/setup/interfaces.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/interfaces.py     (original)
+++ cpsskins/branches/paris-sprint-2006/setup/interfaces.py     Sat May 13 
22:28:54 2006
@@ -128,6 +128,9 @@
     def list(type, context):
         """List all resources of a given type."""
 
+    def purge(context):
+        """Remove all settings"""
+
     def customize(uri, context):
         """Customize a resource."""
 

Modified: cpsskins/branches/paris-sprint-2006/setup/io/utils.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/io/utils.py       (original)
+++ cpsskins/branches/paris-sprint-2006/setup/io/utils.py       Sat May 13 
22:28:54 2006
@@ -209,7 +209,10 @@
     root = document.documentElement
 
     for name in settings:
-        exporter = getMultiAdapter((settings[name], root), IDOMAdapter)
+        setting = settings[name]
+        if setting.isGlobal():
+            continue
+        exporter = getMultiAdapter((setting, root), IDOMAdapter)
         exporter.archive = archive
         exporter.document = document
         exporter.save()
@@ -244,17 +247,24 @@
     uri_mapping = {}
 
     mgr = getThemeManager(context)
-    settings = mgr.getSettings()
-    #settings.purge()
+    resources = getUtility(IResourceManager)
+    resources.purge(context)
 
-    for el in root.getElementsByTagName(u'settings'):
+    for el in root.getElementsByTagName(u'setting'):
         if el.nodeType != Node.ELEMENT_NODE:
              continue
 
-        setting = createObject(u'cpsskins.setting')
-        settings.add(setting)
+        typename = el.getAttribute(u'type')
+        name = el.getAttribute(u'name')
+        title = el.getAttribute(u'title')
+        custom = el.getAttribute(u'custom')
+
+        factory_name = u'cpsskins.%s' % typename.replace('-', '.')
+        resource = createObject(factory_name)
+        resources.register(name=name, title=title, resource=resource,
+                           context=context, custom=custom)
 
-        importer = getMultiAdapter((setting, el), IDOMAdapter)
+        importer = getMultiAdapter((resource, el), IDOMAdapter)
         importer.archive = archive
         importer.document = document
         importer.object_type = typename

Modified: cpsskins/branches/paris-sprint-2006/setup/manager.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/manager.py        (original)
+++ cpsskins/branches/paris-sprint-2006/setup/manager.py        Sat May 13 
22:28:54 2006
@@ -138,6 +138,15 @@
 
         return resource
 
+    ### Management  ################################################
+
+    def purge(self, context=None):
+        for setting in self.list(context=context):
+            if setting.isGlobal():
+                continue
+            uri = IIdentifiable(setting).getURI()
+            self.unregister(uri=uri, context=context)
+
     ### Customization  ################################################
 
     def isGlobal(self, uri=u''):

Modified: cpsskins/branches/paris-sprint-2006/standard/io/setting.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/io/setting.py  (original)
+++ cpsskins/branches/paris-sprint-2006/standard/io/setting.py  Sat May 13 
22:28:54 2006
@@ -41,6 +41,7 @@
         setting_el.setAttribute(u'name', context.name)
         setting_el.setAttribute(u'title', context.title)
         setting_el.setAttribute(u'type', IType(resource).name)
+        setting_el.setAttribute(u'custom', context.isCustom())
         node.appendChild(setting_el)
 
         # export the resource
@@ -49,8 +50,6 @@
         exporter.save()
 
     def load(self):
-        context = self.context
-        node = self.node
-
-
+        # nothing to do
+        pass
 

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 Sat May 
13 22:28:54 2006
@@ -85,9 +85,6 @@
 
         resources.unregister(uri=uri, context=self.context)
 
-        settings = self.getSettings()
-        del settings[zapi.getName(setting)]
-
     def exportSetting(self, uri=u''):
         """Export the setting as an XML file.
         """
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to