[Checkins] SVN: grok/branches/gotcha-configuration-actions/src/grok/ Move grok() and grok_component() to grok.testing. You should not say

Philipp von Weitershausen philikon at philikon.de
Sat Oct 27 11:45:44 EDT 2007


Log message for revision 81130:
  Move grok() and grok_component() to grok.testing.  You should not say
  grok.grok() anymore (though you still can). You should use grok.testing.grok()
  (because it's meant for tests only).
  

Changed:
  U   grok/branches/gotcha-configuration-actions/src/grok/__init__.py
  A   grok/branches/gotcha-configuration-actions/src/grok/testing.py
  U   grok/branches/gotcha-configuration-actions/src/grok/tests/__init__.py

-=-
Modified: grok/branches/gotcha-configuration-actions/src/grok/__init__.py
===================================================================
--- grok/branches/gotcha-configuration-actions/src/grok/__init__.py	2007-10-27 15:45:01 UTC (rev 81129)
+++ grok/branches/gotcha-configuration-actions/src/grok/__init__.py	2007-10-27 15:45:43 UTC (rev 81130)
@@ -40,11 +40,13 @@
 from grok.directive import (context, name, title, template, templatedir,
                             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
 
+# BBB These two functions are meant for test fixtures and should be
+# imported from grok.testing, not from grok.
+from grok.testing import grok, grok_component
+
 from grok.formlib import action, AutoFields, Fields
 from grok.util import url
 

Added: grok/branches/gotcha-configuration-actions/src/grok/testing.py
===================================================================
--- grok/branches/gotcha-configuration-actions/src/grok/testing.py	                        (rev 0)
+++ grok/branches/gotcha-configuration-actions/src/grok/testing.py	2007-10-27 15:45:43 UTC (rev 81130)
@@ -0,0 +1,43 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Grok test helpers
+"""
+from zope.configuration.config import ConfigurationMachine
+from martian import scan
+from grok import zcml
+
+def grok(module_name):
+    config = ConfigurationMachine()
+    zcml.do_grok(module_name, config)
+    config.execute_actions()
+
+def grok_component(name, component,
+                   context=None, module_info=None, templates=None):
+    if module_info is None:
+        obj_module = getattr(component, '__grok_module__', None)
+        if obj_module is None:
+            obj_module = getattr(component, '__module__', None)
+        module_info = scan.module_info_from_dotted_name(obj_module)
+
+    module = module_info.getModule()
+    if context is not None:
+        module.__grok_context__ = context
+    if templates is not None:
+        module.__grok_templates__ = templates
+    config = ConfigurationMachine()
+    result = zcml.the_multi_grokker.grok(name, component,
+                                         module_info=module_info,
+                                         config=config)
+    config.execute_actions()    
+    return result


Property changes on: grok/branches/gotcha-configuration-actions/src/grok/testing.py
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: grok/branches/gotcha-configuration-actions/src/grok/tests/__init__.py
===================================================================
--- grok/branches/gotcha-configuration-actions/src/grok/tests/__init__.py	2007-10-27 15:45:01 UTC (rev 81129)
+++ grok/branches/gotcha-configuration-actions/src/grok/tests/__init__.py	2007-10-27 15:45:43 UTC (rev 81130)
@@ -1,23 +1 @@
-##############################################################################
-#
-# Copyright (c) 2007 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Grok test fixtures
-"""
-from zope.configuration.config import ConfigurationMachine
-import grok as grokpkg
-
-def grok(module_name):
-    config = ConfigurationMachine()
-    grokpkg.grok(module_name, config=config)
-    config.execute_actions()
-
+# make this directory a package



More information about the Checkins mailing list