[Checkins] SVN: z3ext.layout/trunk/src/z3ext/layout/zcml.py fixed registration for typed pagelets

Nikolay Kim fafhrd91 at gmail.com
Thu Jun 18 07:43:09 EDT 2009


Log message for revision 101124:
  fixed registration for typed pagelets

Changed:
  U   z3ext.layout/trunk/src/z3ext/layout/zcml.py

-=-
Modified: z3ext.layout/trunk/src/z3ext/layout/zcml.py
===================================================================
--- z3ext.layout/trunk/src/z3ext/layout/zcml.py	2009-06-18 10:54:24 UTC (rev 101123)
+++ z3ext.layout/trunk/src/z3ext/layout/zcml.py	2009-06-18 11:43:09 UTC (rev 101124)
@@ -349,7 +349,6 @@
                 pass
 
         if iface is not None:
-            tps.append(iface)
             provides.append(iface)
 
     kwargs['type'] = type
@@ -412,13 +411,13 @@
 
     # register pagelet
     for_.append(layer)
-    if tps:
+    if type:
         _context.action(
             discriminator = (
                 'z3ext.layout:registerPagelets',
-                tuple(tps), tuple(for_), layer, name),
+                tuple(type), tuple(for_), layer, name),
             callable = registerTypedPagelets,
-            args = (for_, new_class, tps, name, _context.info))
+            args = (for_, new_class, type, name, _context))
     else:
         _context.action(
             discriminator = (
@@ -438,11 +437,18 @@
             handler('registerAdapter', newClass, required, iface, '', info)
 
 
-def registerTypedPagelets(required, newClass, type, name, info):
-    for iface in type:
-        handler('registerAdapter', newClass, required, iface, name, info)
+def registerTypedPagelets(required, newClass, type, name, _context):
+    for tp in type:
+        iface = queryUtility(IPageletType, tp)
+        if iface is None:
+            try:
+                iface = _context.resolve(tp)
+            except Exception, err:
+                pass
 
+        handler('registerAdapter', newClass, required, iface,name,_context.info)
 
+
 def _handle_allowed_interface(
     _context, allowed_interface, permission, required):
     # Allow access for all names defined by named interfaces



More information about the Checkins mailing list