[Zope3-checkins] SVN: Zope3/trunk/src/zope/configuration/ Add 'files' parameter to <includeOverrides /> as well (works

Philipp von Weitershausen philikon at philikon.de
Sat Jul 23 19:24:37 EDT 2005


Log message for revision 37395:
  Add 'files' parameter to <includeOverrides /> as well (works
  like it does on the <include /> directive).
  

Changed:
  A   Zope3/trunk/src/zope/configuration/tests/samplepackage/baro2.zcml
  U   Zope3/trunk/src/zope/configuration/tests/test_xmlconfig.py
  U   Zope3/trunk/src/zope/configuration/xmlconfig.py

-=-
Copied: Zope3/trunk/src/zope/configuration/tests/samplepackage/baro2.zcml (from rev 37390, Zope3/trunk/src/zope/configuration/tests/samplepackage/baro.zcml)
===================================================================
--- Zope3/trunk/src/zope/configuration/tests/samplepackage/baro.zcml	2005-07-23 01:51:11 UTC (rev 37390)
+++ Zope3/trunk/src/zope/configuration/tests/samplepackage/baro2.zcml	2005-07-23 23:24:37 UTC (rev 37395)
@@ -0,0 +1,6 @@
+<configure>
+
+  <include file="bar1.zcml" />
+  <includeOverrides files="bar2*.zcml" />
+
+</configure>

Modified: Zope3/trunk/src/zope/configuration/tests/test_xmlconfig.py
===================================================================
--- Zope3/trunk/src/zope/configuration/tests/test_xmlconfig.py	2005-07-23 16:02:53 UTC (rev 37394)
+++ Zope3/trunk/src/zope/configuration/tests/test_xmlconfig.py	2005-07-23 23:24:37 UTC (rev 37395)
@@ -456,7 +456,7 @@
     We see that:
 
     - The conflicting actions between bar2.zcml and bar21.zcml have
-      been resolves, and
+      been resolved, and
 
     - The remaining (after conflict resolution) actions from bar2.zcml
       and bar21.zcml have the includepath that they would have if they
@@ -472,7 +472,7 @@
 
     >>> len(foo.data)
     3
-    
+
     >>> data = foo.data.pop(0)
     >>> data.args
     (('x', 'blah'), ('y', 0))
@@ -491,6 +491,43 @@
     >>> print clean_info_path(`data.info`)
     File "tests/samplepackage/bar2.zcml", line 6.2-6.24
 
+
+    We expect the exact same results when using includeOverrides with
+    the ``files`` argument instead of the ``file`` argument.  The
+    baro2.zcml file uses the former:
+
+    >>> context = config.ConfigurationMachine()
+    >>> xmlconfig.registerCommonDirectives(context)
+    >>> path = os.path.join(here, "samplepackage", "baro2.zcml")
+    >>> xmlconfig.include(context, path)
+
+    Actions look like above:
+
+    >>> pprint(clean_actions(context.actions))
+    [{'discriminator': (('x', 'blah'), ('y', 0)),
+      'includepath': ['tests/samplepackage/baro2.zcml',
+                      'tests/samplepackage/bar1.zcml',
+                      'tests/samplepackage/configure.zcml'],
+      'info': 'File "tests/samplepackage/configure.zcml", line 12.2-12.29'},
+     {'discriminator': (('x', 'blah'), ('y', 1)),
+      'includepath': ['tests/samplepackage/baro2.zcml',
+                      'tests/samplepackage/bar1.zcml'],
+      'info': 'File "tests/samplepackage/bar1.zcml", line 5.2-5.24'},
+     {'discriminator': (('x', 'blah'), ('y', 0)),
+      'includepath': ['tests/samplepackage/baro2.zcml'],
+      'info': 'File "tests/samplepackage/bar21.zcml", line 3.2-3.24'},
+     {'discriminator': (('x', 'blah'), ('y', 2)),
+      'includepath': ['tests/samplepackage/baro2.zcml'],
+      'info': 'File "tests/samplepackage/bar2.zcml", line 5.2-5.24'},
+     {'discriminator': (('x', 'blah'), ('y', 1)),
+      'includepath': ['tests/samplepackage/baro2.zcml'],
+      'info': 'File "tests/samplepackage/bar2.zcml", line 6.2-6.24'}]
+
+    >>> context.execute_actions()
+    >>> len(foo.data)
+    3
+    >>> del foo.data[:]
+
     """
 
 def test_XMLConfig():
@@ -590,4 +627,5 @@
         DocTestSuite(),
         ))
 
-if __name__ == '__main__': unittest.main()
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')

Modified: Zope3/trunk/src/zope/configuration/xmlconfig.py
===================================================================
--- Zope3/trunk/src/zope/configuration/xmlconfig.py	2005-07-23 16:02:53 UTC (rev 37394)
+++ Zope3/trunk/src/zope/configuration/xmlconfig.py	2005-07-23 23:24:37 UTC (rev 37395)
@@ -493,7 +493,7 @@
             assert _context.stack[-1].context is context
             _context.stack.pop()
 
-def includeOverrides(_context, file, package=None):
+def includeOverrides(_context, file=None, package=None, files=None):
     """Include zcml file containing overrides
 
     The actions in the included file are added to the context as if they
@@ -510,7 +510,7 @@
     includepath = _context.includepath
 
     # Now we'll include the file. We'll munge the actions after
-    include(_context, file, package)
+    include(_context, file, package, files)
 
     # Now we'll grab the new actions, resolve conflicts,
     # and munge the includepath:



More information about the Zope3-Checkins mailing list