Author: jmorliaguet
Date: Fri Nov 18 01:05:53 2005
New Revision: 1879

Modified:
   cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py
   cpsskins/branches/jmo-perspectives/resources/manager.py
Log:

- added a 'customize' method to convert global settings into local settings



Modified: cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py  
(original)
+++ cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py  Fri Nov 
18 01:05:53 2005
@@ -18,19 +18,18 @@
 __docformat__ = "reStructuredText"
 
 from zope.app.publisher.browser import BrowserView
-from zope.component import getUtility
+from zope.component import getUtilitiesFor
 from zope.app.interface import queryType
 
-from cpsskins.interfaces import ISettings, ISettingType
+from cpsskins.interfaces import ISettings, ISetting, ISettingType
 
 class SiteDesignerView(BrowserView):
 
     def getSettingInfo(self):
-         """Return information about registered resources categorized by type.
-         """
-         info = {}
-         settings = getUtility(ISettings)
-         for setting in settings.values():
-             type = queryType(setting, ISettingType).__identifier__
-             info.setdefault(type, []).append(setting)
-         return info
+        """Return information about registered resources categorized by type.
+        """
+        info = {}
+        for name, setting in getUtilitiesFor(ISetting):
+            type_name = queryType(setting, ISettingType).__identifier__
+            info.setdefault(type_name, []).append(setting)
+        return info

Modified: cpsskins/branches/jmo-perspectives/resources/manager.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/resources/manager.py     (original)
+++ cpsskins/branches/jmo-perspectives/resources/manager.py     Fri Nov 18 
01:05:53 2005
@@ -20,6 +20,7 @@
 from zope.app.component.interfaces.registration import ActiveStatus
 from zope.app.component.site import UtilityRegistration
 from zope.app.container.interfaces import INameChooser
+from zope.app.location.pickling import locationCopy
 from zope.interface import implements, Interface
 from zope.component import getUtilitiesFor, queryUtility, getUtility
 
@@ -44,6 +45,12 @@
     def lookup(name, context, default):
         """Look up a resource."""
 
+    def list(context):
+        """List all resources."""
+
+    def customize(name, context):
+        """Customize a resource."""
+
 class ResourceManager(object):
     """Resource manager utility"""
 
@@ -86,3 +93,18 @@
             if resource_getter is not None:
                 resources.append(resource_getter.getResource())
         return resources
+
+    def customize(self, name=u'', context=None):
+        if context is None:
+            raise ValueError("Must specify a context.")
+
+        setting = queryUtility(self.setting_type, name)
+        if setting is None:
+            raise ValueError("No such setting.")
+
+        resource = None
+        resource_getter = IResource(setting)
+        if resource_getter is not None:
+            resource = locationCopy(resource_getter.getResource())
+
+        self.register(title=setting.title, resource=resource, context=context)
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to