Author: jmorliaguet
Date: Wed Nov  2 11:43:12 2005
New Revision: 28879

Modified:
   z3lab/cpsskins/branches/jmo-perspectives/configuration/accesskeys/meta.zcml
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/accesskeys/metaconfigure.py
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/accesskeys/metadirectives.py
Log:

- access keys can be registered in access key collections outside the 
  cpsskins:accesskeys directive



Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/accesskeys/meta.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/configuration/accesskeys/meta.zcml 
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/configuration/accesskeys/meta.zcml 
Wed Nov  2 11:43:12 2005
@@ -6,7 +6,7 @@
     <complexDirective
         name="accesskeys"
         schema=".metadirectives.IAccessKeysDirective"
-        handler=".metaconfigure.AccessKeys">
+        handler=".metaconfigure.AccessKeyCollection">
 
       <subdirective
           name="accesskey"
@@ -15,6 +15,11 @@
 
     </complexDirective>
 
+    <directive
+       name="accesskey"
+       schema=".metadirectives.IAccessKeyDirective"
+       handler=".metaconfigure.accesskey" />
+
   </directives>
 
 </configure>

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/accesskeys/metaconfigure.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/accesskeys/metaconfigure.py
  (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/accesskeys/metaconfigure.py
  Wed Nov  2 11:43:12 2005
@@ -26,21 +26,49 @@
 accesskey_registry = getUtility(IRegistry, 'accesskeys')
 registered = []
 
-class AccessKeys(object):
+class AccessKeyCollection(object):
 
     def __init__(self, _context, name):
         self._context = _context
         self.name = name
         self.accesskeys = []
 
-    def accesskey(self, _context, key, url):
+    def accesskey(self, _context, key, url, collection):
+        if collection:
+            raise ConfigurationError(
+                "Cannot specify a collection in an accesskeys directive.")
+
         if not key:
             raise ConfigurationError("Must specify a key.")
 
         if not url:
             raise ConfigurationError("Must specify a url.")
 
+        if key in self.accesskeys:
+            raise ConfigurationError("Access key already registered.")
+
         self.accesskeys.append({'key': key, 'url': url})
 
     def __call__(self):
         accesskey_registry.register(self.name, self.accesskeys)
+
+
+def accesskey(_context, key, url, collection):
+    if not collection:
+        raise ConfigurationError("Must specify an access key collection.")
+
+    if not key:
+        raise ConfigurationError("Must specify a key.")
+
+    if not url:
+        raise ConfigurationError("Must specify a url.")
+
+    if collection not in accesskey_registry:
+        raise ConfigurationError("No such access key collection.")
+
+    accesskeys = accesskey_registry[collection]
+    if key in accesskeys:
+        raise ConfigurationError("Access key already registered.")
+
+    accesskeys.append({'key': key, 'url': url})
+

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/accesskeys/metadirectives.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/accesskeys/metadirectives.py
 (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/accesskeys/metadirectives.py
 Wed Nov  2 11:43:12 2005
@@ -27,7 +27,7 @@
 
     name = TextLine(
         title=_("Name"),
-        description=_("The name of the access key set."),
+        description=_("The name of the access key collection."),
         required=False,
         )
 
@@ -45,4 +45,11 @@
         required=False,
         )
 
+    collection = TextLine(
+        title=_("Collection"),
+        description=_("The access key collection."),
+        required=False,
+        )
+
+
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to