[Checkins] SVN: grok/branches/gotcha-configuration-actions/src/grok/ Get rid of grok_component. It doesn't really make sense anymore after the refactoring

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


Log message for revision 80777:
  Get rid of grok_component. It doesn't really make sense anymore after the refactoring
  of pre- and post-checks into all the other grokkers.
  

Changed:
  U   grok/branches/gotcha-configuration-actions/src/grok/__init__.py
  U   grok/branches/gotcha-configuration-actions/src/grok/_grok.py
  U   grok/branches/gotcha-configuration-actions/src/grok/interfaces.py
  D   grok/branches/gotcha-configuration-actions/src/grok/tests/grokker/grokcomponent.py

-=-
Modified: grok/branches/gotcha-configuration-actions/src/grok/__init__.py
===================================================================
--- grok/branches/gotcha-configuration-actions/src/grok/__init__.py	2007-10-10 08:54:49 UTC (rev 80776)
+++ grok/branches/gotcha-configuration-actions/src/grok/__init__.py	2007-10-10 08:58:51 UTC (rev 80777)
@@ -41,7 +41,6 @@
                             provides, baseclass, global_utility, local_utility,
                             permissions, require, site, layer)
 from grok._grok import do_grok as grok  # Avoid name clash within _grok
-from grok._grok import grok_component
 from grok.decorators import subscribe, adapter, implementer
 from martian.error import GrokError, GrokImportError
 

Modified: grok/branches/gotcha-configuration-actions/src/grok/_grok.py
===================================================================
--- grok/branches/gotcha-configuration-actions/src/grok/_grok.py	2007-10-10 08:54:49 UTC (rev 80776)
+++ grok/branches/gotcha-configuration-actions/src/grok/_grok.py	2007-10-10 08:58:51 UTC (rev 80777)
@@ -80,13 +80,6 @@
         config=config
         )
 
-def grok_component(name, component,
-                   context=None, module_info=None, templates=None):
-    return the_multi_grokker.grok(name, component,
-                                  context=context,
-                                  module_info=module_info,
-                                  templates=templates)
-
 def prepare_grok(name, module, kw):
     module_info = scan.module_info_from_module(
         module, exclude_filter=skip_tests)

Modified: grok/branches/gotcha-configuration-actions/src/grok/interfaces.py
===================================================================
--- grok/branches/gotcha-configuration-actions/src/grok/interfaces.py	2007-10-10 08:54:49 UTC (rev 80776)
+++ grok/branches/gotcha-configuration-actions/src/grok/interfaces.py	2007-10-10 08:58:51 UTC (rev 80777)
@@ -204,21 +204,6 @@
     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.
         """

Deleted: grok/branches/gotcha-configuration-actions/src/grok/tests/grokker/grokcomponent.py
===================================================================
--- grok/branches/gotcha-configuration-actions/src/grok/tests/grokker/grokcomponent.py	2007-10-10 08:54:49 UTC (rev 80776)
+++ grok/branches/gotcha-configuration-actions/src/grok/tests/grokker/grokcomponent.py	2007-10-10 08:58:51 UTC (rev 80777)
@@ -1,61 +0,0 @@
-"""
-
-Let's first grok the meta module to define some basic grokkers::
-
-  >>> import grok
-  >>> grok.tests.grok('grok.meta')
-  
-It is possible to grok an individual component. Let's define an adapter::
-
-  >>> from zope.interface import Interface
-  >>> class IMyInterface(Interface):
-  ...   pass
-  >>> class SomeClass(object):
-  ...   pass
-  >>> class MyAdapter(grok.Adapter):
-  ...   grok.provides(IMyInterface)
-  ...   grok.context(SomeClass)
-
-To grok this adapter, you can simply write this::
-
-  >>> grok.tests.grok_component('MyAdapter', MyAdapter)
-  True
-
-We can now use the adapter::
-
-  >>> instance = SomeClass()
-  >>> adapter = IMyInterface(instance)
-  >>> isinstance(adapter, MyAdapter)
-  True
-
-We can use grok_component with only two arguments because we know the
-adapter grokker is not looking for more. Sometimes we need to supply
-an extra argument however::
-
-  >>> class ISecondInterface(Interface):
-  ...   pass
-  >>> class SecondAdapter(grok.Adapter):
-  ...   grok.provides(ISecondInterface)
-
-This adapter does not supply its own context. Trying to do what we did
-before will therefore fail::
-
-  >>> grok.tests.grok_component('SecondAdapter', SecondAdapter)
-  Traceback (most recent call last):
-    ...
-  GrokError: No module-level context for <class 'grok.tests.grokker.grokcomponent.SecondAdapter'>, please use grok.context.
-
-So we need to supply the context ourselves::
-
-  >>> grok.tests.grok_component('SecondAdapter', SecondAdapter, context=SomeClass)
-  True
-
-Now we can use the SecondAdapter as well::
-
-  >>> adapter = ISecondInterface(instance)
-  >>> isinstance(adapter, SecondAdapter)
-  True
-
-The next optional argument is module_info and the final argument is
-templates.
-"""



More information about the Checkins mailing list