[Checkins] SVN: grok/branches/grok-martian/src/grok/ Add simple support for grokking an individual component.

Martijn Faassen faassen at infrae.com
Wed Jun 20 16:14:57 EDT 2007


Log message for revision 76860:
  Add simple support for grokking an individual component.
  

Changed:
  U   grok/branches/grok-martian/src/grok/_grok.py
  U   grok/branches/grok-martian/src/grok/interfaces.py

-=-
Modified: grok/branches/grok-martian/src/grok/_grok.py
===================================================================
--- grok/branches/grok-martian/src/grok/_grok.py	2007-06-20 19:24:38 UTC (rev 76859)
+++ grok/branches/grok-martian/src/grok/_grok.py	2007-06-20 20:14:56 UTC (rev 76860)
@@ -79,6 +79,17 @@
         _bootstrapped = True
     martian.grok_dotted_name(dotted_name, the_module_grokker)
 
+def grok_component(name, component,
+                   context=None, module_info=None, templates=None):
+    kw = {}
+    if context is not None:
+        kw['context'] = context
+    if module_info is not None:
+        kw['module_info'] = module_info
+    if templates is not None:
+        kw['templates'] = templates
+    return the_multi_grokker.grok(name, component, **kw)
+
 def prepare_grok(name, module, kw):
     module_info = scan.module_info_from_module(module)
     
@@ -104,7 +115,8 @@
                         % (module_info.dotted_name,
                            ', '.join(unassociated)), module_info)
 
-the_module_grokker = martian.ModuleGrokker(martian.MetaMultiGrokker(),
+the_multi_grokker = martian.MetaMultiGrokker()
+the_module_grokker = martian.ModuleGrokker(the_multi_grokker,
                                            prepare=prepare_grok,
                                            finalize=finalize_grok)
 

Modified: grok/branches/grok-martian/src/grok/interfaces.py
===================================================================
--- grok/branches/grok-martian/src/grok/interfaces.py	2007-06-20 19:24:38 UTC (rev 76859)
+++ grok/branches/grok-martian/src/grok/interfaces.py	2007-06-20 20:14:56 UTC (rev 76860)
@@ -190,6 +190,21 @@
     def grok(dotted_name):
         """Grok a module or package specified by ``dotted_name``."""
 
+    def grok_component(name, component, context=None, module_info=None,
+                       templates=None):
+        """Grok an arbitrary object. Can be useful during testing.
+
+        name - the name of the component (class name, or global instance name
+               as it would appear in a module).
+        component - the object (class, etc) to grok.
+        context - the context object (optional).
+        module_info - the module being grokked (optional).
+        templates - the templates registry (optional).
+
+        Note that context, module_info and templates might be required
+        for some grokkers which rely on them.
+        """
+    
     def url(request, obj, name=None):
         """Generate the URL to an object with optional name attached.
         """



More information about the Checkins mailing list