[Checkins] SVN: grokcore.component/trunk/ Port changes on the ZCML directive from 1.x branch

Sylvain Viollon sylvain at infrae.com
Fri Jul 23 08:11:36 EDT 2010


Log message for revision 114956:
  Port changes on the ZCML directive from 1.x branch
  

Changed:
  U   grokcore.component/trunk/CHANGES.txt
  U   grokcore.component/trunk/src/grokcore/component/zcml.py

-=-
Modified: grokcore.component/trunk/CHANGES.txt
===================================================================
--- grokcore.component/trunk/CHANGES.txt	2010-07-23 11:51:04 UTC (rev 114955)
+++ grokcore.component/trunk/CHANGES.txt	2010-07-23 12:11:36 UTC (rev 114956)
@@ -11,7 +11,11 @@
 
 * Tiny dependency adjustment: moved zope.event to test dependencies.
 
+* Port from 1.x branch exclude parameter to the Grok ZCML directive.
 
+* Port from 1.x branch the ignore of testing.py modules.
+
+
 2.0 (2009-09-16)
 ----------------
 

Modified: grokcore.component/trunk/src/grokcore/component/zcml.py
===================================================================
--- grokcore.component/trunk/src/grokcore/component/zcml.py	2010-07-23 11:51:04 UTC (rev 114955)
+++ grokcore.component/trunk/src/grokcore/component/zcml.py	2010-07-23 12:11:36 UTC (rev 114956)
@@ -15,40 +15,57 @@
 
 from zope.interface import Interface
 from zope.configuration.fields import GlobalObject
-#from zope.configuration.config import ConfigurationMachine
+from zope.schema import TextLine
 
 import martian
-#from martian import scan
-#from martian.error import GrokError
 
+
 class IGrokDirective(Interface):
     """Grok a package or module."""
 
     package = GlobalObject(
         title=u"Package",
         description=u"The package or module to be analyzed by grok.",
-        required=False,
-        )
+        required=False)
 
+    exclude = TextLine(
+        title=u"Exclude",
+        description=u"Name to exclude in the grokking process.",
+        required=False)
+
+
 # add a cleanup hook so that grok will bootstrap itself again whenever
 # the Component Architecture is torn down.
 def resetBootstrap():
     # we need to make sure that the grokker registry is clean again
     the_module_grokker.clear()
+
 from zope.testing.cleanup import addCleanUp
 addCleanUp(resetBootstrap)
 
 the_multi_grokker = martian.MetaMultiGrokker()
 the_module_grokker = martian.ModuleGrokker(the_multi_grokker)
 
+
 def skip_tests(name):
-    return name in ['tests', 'ftests']
+    return name in ['tests', 'ftests', 'testing']
 
-def grokDirective(_context, package):
-    do_grok(package.__name__, _context)
 
-def do_grok(dotted_name, config):
+def grokDirective(_context, package, exclude=None):
+    if not exclude:
+        exclude = None
+    do_grok(package.__name__, _context, extra_exclude=exclude)
+
+
+def do_grok(dotted_name, config, extra_exclude=None):
+    if extra_exclude is not None:
+
+        def exclude_filter(name):
+            return skip_tests(name) or extra_exclude == name
+
+    else:
+        exclude_filter = skip_tests
+
     martian.grok_dotted_name(
-        dotted_name, the_module_grokker, exclude_filter=skip_tests,
-        config=config
-        )
+        dotted_name, the_module_grokker, exclude_filter=exclude_filter,
+        config=config)



More information about the checkins mailing list