Author: jmorliaguet
Date: Thu Mar 23 22:52:48 2006
New Revision: 2706

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

- test 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 22:52:48 2006
@@ -51,10 +51,12 @@
     ...     """A dummy resource for testing.
     ...     """
     ...     implements(IDummyResource)
-    ...     def __init__(self, id=u''):
-    ...         self.id = id
+    ...     def __init__(self, title=u''):
+    ...         self.title = title
+    ...     def setTitle(self, title=u''):
+    ...         self.title = title
     ...     def __repr__(self):
-    ...         return '<Dummy resource: %s>' % self.id
+    ...         return '<Dummy resource: %s>' % self.title
 
 We create a couple of resources:
 
@@ -71,10 +73,10 @@
 
 But none of the above resources are available yet in the application:
 
-    >>> resources.lookup(u'setting1') is None
+    >>> resources.lookup(u'resource1') is None
     True
 
-    >>> resources.lookup(u'setting2') is None
+    >>> resources.lookup(u'resource2') is None
     True
 
 Registering resources
@@ -82,15 +84,15 @@
 
 Resources need to be registered, so we register them:
 
-    >>> resources.register(name=u'setting1', title=u'Setting 1',
+    >>> resources.register(name=u'resource1', title=u'Resource 1',
     ...                    resource=resource1)
 
 and we look up the registered resource:
 
-    >>> resources.lookup(u'setting1')
+    >>> resources.lookup(u'resource1')
     <Dummy resource: resource1>
 
-    >>> resources.lookup('setting2')
+    >>> resources.lookup('resource2')
 
 We can get the complete list of registered resources:
 
@@ -99,12 +101,12 @@
 
 Now we register the second resource:
 
-    >>> resources.register(name=u'setting2', title=u'Setting 2',
+    >>> resources.register(name=u'resource2', title=u'Resource 2',
     ...                    resource=resource2)
 
 and look it up in the registry:
 
-    >>> resources.lookup(u'setting2')
+    >>> resources.lookup(u'resource2')
     <Dummy resource: resource2>
 
 or we find it by listing all registered resources:
@@ -115,30 +117,31 @@
 
 Trying to unregister a global resource raises an error:
 
-    >>> resources.isGlobal(u'setting1')
+    >>> resources.isGlobal(u'resource1')
     True
 
-    >>> resources.unregister(name=u'setting1', context=root)
+    >>> resources.unregister(name=u'resource1', context=root)
     Traceback (most recent call last):
     ...
-    ValueError: No such local setting: 'setting1'
+    ValueError: No such local setting: 'resource1'
 
 so we register a local resource, we do this by passing a context to register():
 
-    >>> resources.register(name=u'setting3', title=u'Setting 3',
+    >>> resources.register(name=u'resource3', title=u'Resource 3',
     ...                    resource=resource3, context=root)
 
 We now have a local resource in the context of the root folder:
 
-    >>> resources.isLocal(name=u'setting3', context=root)
+    >>> resources.isLocal(name=u'resource3', context=root)
     True
 
 but for the application and in the context of the root folder there is no
 difference between local and global resources:
 
     >>> pprint(resources.list(type=IDummyResource, context=root))
-    [<Dummy resource: resource1>, <Dummy resource: resource2>, <Dummy
-    resource: resource3>]
+    [<Dummy resource: resource1>,
+     <Dummy resource: resource3>,
+     <Dummy resource: resource2>]
 
 
 Unregistering resources
@@ -146,7 +149,7 @@
 
 when unregistering a resource, a context must be given:
 
-    >>> resources.unregister(name='setting3')
+    >>> resources.unregister(name='resource3')
     Traceback (most recent call last):
     ...
     ValueError: Must specify a context.
@@ -160,7 +163,79 @@
 
 so we pass both:
 
-    >>> resources.unregister(name='setting3', context=root)
+    >>> resources.unregister(name='resource3', context=root)
 
+and the resource is no longer available:
 
-global settings cannot be modified but they can be customized:
+    >>> resources.lookup(u'resource3') is None
+    True
+
+    >>> pprint(resources.list(type=IDummyResource, context=root))
+    [<Dummy resource: resource1>,
+     <Dummy resource: resource2>]
+
+
+Customizing resources
+---------------------
+
+Global settings cannot be modified but they can be customized:
+
+The context in which the resource is customized must be given:
+
+    >>> resources.customize(u'resource1')
+    Traceback (most recent call last):
+    ...
+    ValueError: Must specify a context.
+
+so we pass the context:
+
+    >>> resources.customize(u'resource1', context=root)
+
+'resource1' is now registered as a local resource:
+
+    >>> resources.isLocal(u'resource1', context=root)
+    True
+
+the customized resource is still available as a global resource:
+
+    >>> resources.isGlobal(u'resource1')
+    True
+
+but when we look up 'resource1' in the context of the root folder, we get the
+customized resource:
+
+Let us modify the customized resource:
+
+    >>> r1 = resources.lookup(u'resource1', context=root)
+    >>> r1.setTitle('Customized resource 1')
+
+    >>> r1
+    <Dummy resource: Customized resource 1>
+
+the global resource is unchanged:
+
+    >>> resources.lookup(u'resource1')
+    <Dummy resource: resource1>
+
+
+Removing customizations
+-----------------------
+
+'resource1' is now customized, to remove the customization we must specify
+the context in which the resource was customized:
+
+    >>> resources.decustomize(u'resource1')
+    Traceback (most recent call last):
+    ...
+    ValueError: Must specify a context.
+
+    >>> resources.decustomize(u'resource1', context=root)
+
+now in the context of the root folder, 'resource1' is no longer different
+from the global resource:
+
+    >>> resources.lookup(u'resource1', context=root)
+    <Dummy resource: resource1>
+
+    >>> resources.lookup(u'resource1')
+    <Dummy resource: resource1>

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 22:52:48 2006
@@ -126,7 +126,10 @@
         if context is None:
             raise ValueError("Must specify a context.")
 
-        setting = self._getSetting(name)
+        setting = queryUtility(ISetting, name)
+        if setting is None:
+            raise ValueError("No such setting: '%s'." % name)
+
         resource = None
         resource_getter = IResource(setting)
         if resource_getter is not None:
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to