Author: jmorliaguet
Date: Thu Mar 23 23:07:37 2006
New Revision: 2707

Modified:
   cpsskins/branches/jmo-perspectives/setup/README.txt
   cpsskins/branches/jmo-perspectives/setup/interfaces.py
   cpsskins/branches/jmo-perspectives/setup/manager.py
Log:

- test / API Updates



Modified: cpsskins/branches/jmo-perspectives/setup/README.txt
==============================================================================
--- cpsskins/branches/jmo-perspectives/setup/README.txt (original)
+++ cpsskins/branches/jmo-perspectives/setup/README.txt Thu Mar 23 23:07:37 2006
@@ -204,6 +204,9 @@
 but when we look up 'resource1' in the context of the root folder, we get the
 customized resource:
 
+    >>> resources.isCustom(u'resource1', context=root)
+    True
+
 Let us modify the customized resource:
 
     >>> r1 = resources.lookup(u'resource1', context=root)
@@ -231,11 +234,12 @@
 
     >>> resources.decustomize(u'resource1', context=root)
 
-now in the context of the root folder, 'resource1' is no longer different
-from the global resource:
+now in the context of the root folder, 'resource1' is the global resource 
+again.
 
     >>> resources.lookup(u'resource1', context=root)
     <Dummy resource: resource1>
 
     >>> resources.lookup(u'resource1')
     <Dummy resource: resource1>
+

Modified: cpsskins/branches/jmo-perspectives/setup/interfaces.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/setup/interfaces.py      (original)
+++ cpsskins/branches/jmo-perspectives/setup/interfaces.py      Thu Mar 23 
23:07:37 2006
@@ -83,7 +83,11 @@
         """Customize a resource."""
 
     def isGlobal(name):
-        """Returns true if the setting is global"""
+        """Returns true if the resource global"""
 
     def isLocal(name):
-        """Returns true if the setting is local"""
+        """Returns true if the resource is local"""
+
+    def isCustom(name, context):
+        """Returns true if the resource has been customized"""
+

Modified: cpsskins/branches/jmo-perspectives/setup/manager.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/setup/manager.py (original)
+++ cpsskins/branches/jmo-perspectives/setup/manager.py Thu Mar 23 23:07:37 2006
@@ -40,6 +40,10 @@
     def __init__(self, context=None):
         self.context = context
 
+    ###################################################################
+    # Registration
+    ###################################################################
+
     def register(self, name=u'', title=u'', resource=None, filename=None,
                        custom=False, context=None):
         """Register the setting as a utility.
@@ -85,6 +89,10 @@
                 del settings[name]
                 break
 
+    ###################################################################
+    # Finding resources
+    ###################################################################
+
     def lookup(self, name=u'', context=None, default=None):
         if not name:
             raise KeyError("Must specify a resource name.")
@@ -110,17 +118,27 @@
             resources.append(resource)
         return resources
 
+    ###################################################################
+    # Customization
+    ###################################################################
+
+    def isGlobal(self, name=u''):
+        setting = queryUtility(ISetting, name)
+        if setting is None:
+            raise ValueError("No such setting: '%s'." % name)
+        return IGlobalSetting.providedBy(setting)
+
     def isLocal(self, name=u'', context=None):
         setting = queryUtility(ISetting, name, context=context)
         if setting is None:
             raise ValueError("No such setting: '%s'." % name)
         return ILocalSetting.providedBy(setting)
 
-    def isGlobal(self, name=u''):
-        setting = queryUtility(ISetting, name)
+    def isCustom(self, name=u'', context=None):
+        setting = queryUtility(ISetting, name, context=context)
         if setting is None:
             raise ValueError("No such setting: '%s'." % name)
-        return IGlobalSetting.providedBy(setting)
+        return ILocalSetting.providedBy(setting) and setting.custom
 
     def customize(self, name=u'', context=None):
         if context is None:
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to