[Checkins] SVN: megrok.kss/trunk/src/megrok/kss/grokker.py update grokker for Z3 actions

Godefroid Chapelle gotcha at bubblenet.be
Tue Nov 27 14:57:30 EST 2007


Log message for revision 81992:
  update grokker for Z3 actions

Changed:
  U   megrok.kss/trunk/src/megrok/kss/grokker.py

-=-
Modified: megrok.kss/trunk/src/megrok/kss/grokker.py
===================================================================
--- megrok.kss/trunk/src/megrok/kss/grokker.py	2007-11-27 19:34:19 UTC (rev 81991)
+++ megrok.kss/trunk/src/megrok/kss/grokker.py	2007-11-27 19:57:29 UTC (rev 81992)
@@ -22,41 +22,49 @@
 class KSSActionsGrokker(martian.ClassGrokker):
     component_class = KSSActions
 
-    def grok(self, name, factory, context, module_info, templates):
+    def grok(self, name, factory, module_info, config, **kw):
+        context = module_info.getAnnotation('grok.context', None)
         view_context = util.determine_class_context(factory, context)
-        methods = util.methods_from_class(factory)
-
         # XXX We should really not make __FOO__ methods available to
         # the outside -- need to discuss how to restrict such things.
-        # this is a trial ;-)
-        methods = [method for method in methods if not method.__name__.startswith('_')]
+        methods = util.methods_from_class(factory)
 
         default_permission = get_default_permission(factory)
 
         for method in methods:
+            name = method.__name__
+            if name.startswith('__'):
+                continue
+
             # Create a new class with a __view_name__ attribute so the
             # KSSServerAction class knows what method to call.
         
             #We should allow name directives on methods
             #view_name = util.class_annotation(factory, 'grok.name',
             #                                  factory_name)
+            
             method_view = type(
                 factory.__name__, (factory, BrowserPage),
-                {'__view_name__': method.__name__}
+                {'__view_name__': name}
                 )
-            #if method.__name__ == 'welcome':
-            #    import pdb; pdb.set_trace() 
-            component.provideAdapter(
-                factory = method_view, 
-                adapts = (view_context, IDefaultBrowserLayer),
-                provides = interface.Interface,
-                name=method.__name__)
 
+            adapts = (view_context, IDefaultBrowserLayer)
+            config.action(
+                discriminator=('adapter', adapts, interface.Interface, name),
+                callable=component.provideAdapter,
+                args=(method_view, adapts, interface.Interface, name),
+                )
+
             # Protect method_view with either the permission that was
             # set on the method, the default permission from the class
             # level or zope.Public.
-
             permission = getattr(method, '__grok_require__',
                                  default_permission)
-            make_checker(factory, method_view, permission)
+
+            config.action(
+                discriminator=('protectName', method_view, '__call__'),
+                callable=make_checker,
+                args=(factory, method_view, permission),
+                )
         return True
+



More information about the Checkins mailing list