[Checkins] SVN: grok/branches/gotcha-configuration-actions/src/grok/ Move the check for unassociated templates from the finalize function to a grokker.

Philipp von Weitershausen philikon at philikon.de
Wed Oct 10 04:52:28 EDT 2007


Log message for revision 80775:
  Move the check for unassociated templates from the finalize function to a grokker.
  The finalize function can go away completely now which helps splitting up the
  grokkers to different packages tremendously.
  

Changed:
  U   grok/branches/gotcha-configuration-actions/src/grok/_grok.py
  U   grok/branches/gotcha-configuration-actions/src/grok/meta.py

-=-
Modified: grok/branches/gotcha-configuration-actions/src/grok/_grok.py
===================================================================
--- grok/branches/gotcha-configuration-actions/src/grok/_grok.py	2007-10-10 08:46:41 UTC (rev 80774)
+++ grok/branches/gotcha-configuration-actions/src/grok/_grok.py	2007-10-10 08:52:28 UTC (rev 80775)
@@ -92,20 +92,6 @@
         module, exclude_filter=skip_tests)
     kw['module_info'] = module_info
 
-def finalize_grok(name, module, kw):
-    module_info = kw['module_info']
-    templates = module_info.getAnnotation('grok.templates', None)
-    if templates is None:
-        return
-    unassociated = list(templates.listUnassociated())
-    if unassociated:
-        raise GrokError("Found the following unassociated template(s) when "
-                        "grokking %r: %s.  Define view classes inheriting "
-                        "from grok.View to enable the template(s)."
-                        % (module_info.dotted_name,
-                           ', '.join(unassociated)), module_info)
-
 the_multi_grokker = martian.MetaMultiGrokker()
 the_module_grokker = martian.ModuleGrokker(the_multi_grokker,
-                                           prepare=prepare_grok,
-                                           finalize=finalize_grok)
+                                           prepare=prepare_grok)

Modified: grok/branches/gotcha-configuration-actions/src/grok/meta.py
===================================================================
--- grok/branches/gotcha-configuration-actions/src/grok/meta.py	2007-10-10 08:46:41 UTC (rev 80774)
+++ grok/branches/gotcha-configuration-actions/src/grok/meta.py	2007-10-10 08:52:28 UTC (rev 80775)
@@ -346,6 +346,23 @@
         return True
 
 
+class UnassociatedTemplatesGrokker(martian.GlobalGrokker):
+    priority = -1001
+
+    def grok(self, name, module, module_info, config, **kw):
+        templates = module_info.getAnnotation('grok.templates', None)
+        if templates is None:
+            return False
+        unassociated = list(templates.listUnassociated())
+        if unassociated:
+            raise GrokError("Found the following unassociated template(s) when "
+                            "grokking %r: %s.  Define view classes inheriting "
+                            "from grok.View to enable the template(s)."
+                            % (module_info.dotted_name,
+                               ', '.join(unassociated)), module_info)
+        return True
+
+
 class SubscriberGrokker(martian.GlobalGrokker):
 
     def grok(self, name, module, module_info, config, **kw):



More information about the Checkins mailing list