[Checkins] SVN: grok/branches/philikon-methodgrokker/src/grok/meta.py Clean up.

Philipp von Weitershausen philikon at philikon.de
Wed May 21 18:49:29 EDT 2008


Log message for revision 86901:
  Clean up.
  

Changed:
  U   grok/branches/philikon-methodgrokker/src/grok/meta.py

-=-
Modified: grok/branches/philikon-methodgrokker/src/grok/meta.py
===================================================================
--- grok/branches/philikon-methodgrokker/src/grok/meta.py	2008-05-21 22:45:03 UTC (rev 86900)
+++ grok/branches/philikon-methodgrokker/src/grok/meta.py	2008-05-21 22:49:29 UTC (rev 86901)
@@ -87,26 +87,28 @@
 
 
 class MethodGrokker(martian.ClassGrokker):
-    grok.baseclass() # XXX
+    grok.baseclass()
 
-    # Use a tuple instead of a list here to make it immutable, just to be safe
-    directives = ()
-
     def grok(self, name, class_, module_info=None, **kw):
         module = None
         if module_info is not None:
             module = module_info.getModule()
 
-        # Populate the data dict with information from the directives:
+        # Populate the data dict with information from class or module
         for directive in self.directives:
             kw[directive.name] = directive.get(class_, module, **kw)
 
         results = []
         for method in public_methods_from_class(class_):
+            # Directives may also be applied to methods, so let's
+            # check each directive and potentially override the
+            # class-level value with a value from the method *locally*.
             data = kw.copy()
-            for bound_directive in self.directives:
-                directive = bound_directive.directive
-                data[bound_directive.name] = directive.store.get(directive, method, data[bound_directive.name])
+            for bound_dir in self.directives:
+                directive = bound_dir.directive
+                class_value = data[bound_dir.name]
+                data[bound_dir.name] = directive.store.get(directive, method,
+                                                           default=class_value)
             results.append(self.execute(class_, method, **data))
 
         if not results:



More information about the Checkins mailing list