[Checkins] SVN: z3c.unconfigure/trunk/src/z3c/unconfigure/ Make unconfigure work with other overrides

Philipp von Weitershausen philikon at philikon.de
Wed Aug 6 09:39:45 EDT 2008


Log message for revision 89441:
  Make unconfigure work with other overrides
  

Changed:
  U   z3c.unconfigure/trunk/src/z3c/unconfigure/config.py
  A   z3c.unconfigure/trunk/src/z3c/unconfigure/testfixtures/overrides2.zcml
  U   z3c.unconfigure/trunk/src/z3c/unconfigure/tests.py
  A   z3c.unconfigure/trunk/src/z3c/unconfigure/tests.txt

-=-
Modified: z3c.unconfigure/trunk/src/z3c/unconfigure/config.py
===================================================================
--- z3c.unconfigure/trunk/src/z3c/unconfigure/config.py	2008-08-06 13:33:00 UTC (rev 89440)
+++ z3c.unconfigure/trunk/src/z3c/unconfigure/config.py	2008-08-06 13:39:44 UTC (rev 89441)
@@ -45,8 +45,13 @@
                 # configured in the first place.  Ignore.
                 continue
 
-            # An action by the same discriminator has been found,
-            # let's remove it from the configuration machine's actions
-            # list.
-            self.context.actions.remove(action)
+            # An action with the same discriminator has been found.
+            # We can't remove it because we mustn't change the length
+            # of the actions list (because includeOverrides relies on
+            # this not to change and we could easily be included via
+            # includeOverrides).
+            i = self.context.actions.index(action)
+            self.context.actions[i] = (None, None)
+
+            # Action has been replaced, no longer need to remember.
             del unique[discriminator]

Added: z3c.unconfigure/trunk/src/z3c/unconfigure/testfixtures/overrides2.zcml
===================================================================
--- z3c.unconfigure/trunk/src/z3c/unconfigure/testfixtures/overrides2.zcml	                        (rev 0)
+++ z3c.unconfigure/trunk/src/z3c/unconfigure/testfixtures/overrides2.zcml	2008-08-06 13:39:44 UTC (rev 89441)
@@ -0,0 +1,6 @@
+<configure>
+  <lolcat who="I" canhas="hamburger" />
+  <unconfigure>
+    <print msg="LOL!" />
+  </unconfigure>
+</configure>
\ No newline at end of file


Property changes on: z3c.unconfigure/trunk/src/z3c/unconfigure/testfixtures/overrides2.zcml
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: z3c.unconfigure/trunk/src/z3c/unconfigure/tests.py
===================================================================
--- z3c.unconfigure/trunk/src/z3c/unconfigure/tests.py	2008-08-06 13:33:00 UTC (rev 89440)
+++ z3c.unconfigure/trunk/src/z3c/unconfigure/tests.py	2008-08-06 13:39:44 UTC (rev 89441)
@@ -66,5 +66,5 @@
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest(DocFileSuite('README.txt'))
+    suite.addTest(DocFileSuite('tests.txt'))
     return suite
-

Added: z3c.unconfigure/trunk/src/z3c/unconfigure/tests.txt
===================================================================
--- z3c.unconfigure/trunk/src/z3c/unconfigure/tests.txt	                        (rev 0)
+++ z3c.unconfigure/trunk/src/z3c/unconfigure/tests.txt	2008-08-06 13:39:44 UTC (rev 89441)
@@ -0,0 +1,46 @@
+Tests that are not documentation
+================================
+
+Unconfiguration and other overrides
+-----------------------------------
+
+When placing an ``unconfigure`` grouping directive in an overrides
+file together with other overrides, things should continue to work
+like you'd expect: the overrides directives override things and the
+``unconfigure`` directive filters actions.
+
+Let's consider this configuration:
+
+  >>> cat('lolcat.zcml')
+  <configure>
+    <print msg="Hello World!" />
+    <print msg="Important configuration here." />
+    <lolcat who="I" canhas="cheezburger" />
+    <print msg="Goodbye World!" />
+    <print msg="LOL!" />
+    <print msg="This is the last directive" />
+  </configure>
+
+And a file with one override and one "unconfiguration":
+
+  >>> cat('overrides2.zcml')
+  <configure>
+    <lolcat who="I" canhas="hamburger" />
+    <unconfigure>
+      <print msg="LOL!" />
+    </unconfigure>
+  </configure>
+
+It works as you'd expect:
+
+  >>> zcml("""
+  ... <configure>
+  ...   <include file="lolcat.zcml" />
+  ...   <includeOverrides file="overrides2.zcml" />
+  ... </configure>
+  ... """)
+  Hello World!
+  Important configuration here.
+  Goodbye World!
+  This is the last directive
+  I can has hamburger?


Property changes on: z3c.unconfigure/trunk/src/z3c/unconfigure/tests.txt
___________________________________________________________________
Name: svn:eol-style
   + native



More information about the Checkins mailing list