[Checkins] SVN: z3c.unconfigure/trunk/ Bugfix: <unconfigure> <include file="..." /> </unconfigure> now works.

Marius Gedminas cvs-admin at zope.org
Thu Oct 25 09:40:16 UTC 2012


Log message for revision 128144:
  Bugfix: <unconfigure> <include file="..." /> </unconfigure> now works.
  
  

Changed:
  U   z3c.unconfigure/trunk/CHANGES.txt
  U   z3c.unconfigure/trunk/src/z3c/unconfigure/README.txt
  U   z3c.unconfigure/trunk/src/z3c/unconfigure/config.py

-=-
Modified: z3c.unconfigure/trunk/CHANGES.txt
===================================================================
--- z3c.unconfigure/trunk/CHANGES.txt	2012-10-25 09:32:02 UTC (rev 128143)
+++ z3c.unconfigure/trunk/CHANGES.txt	2012-10-25 09:40:16 UTC (rev 128144)
@@ -1,10 +1,3 @@
-Issues
-======
-
-* Unconfiguring an entire zcml file (include statement inside an unconfigure
-block) currently seems to be broken. (Test fails.)
-
-
 Changes
 =======
 
@@ -16,6 +9,9 @@
 
 * Dropped support for zope.configuration 3.7.x and older.
 
+* Unconfiguring an entire zcml file (include statement inside an unconfigure
+  block) now works.
+
 1.0.1 (2008-08-07)
 ------------------
 

Modified: z3c.unconfigure/trunk/src/z3c/unconfigure/README.txt
===================================================================
--- z3c.unconfigure/trunk/src/z3c/unconfigure/README.txt	2012-10-25 09:32:02 UTC (rev 128143)
+++ z3c.unconfigure/trunk/src/z3c/unconfigure/README.txt	2012-10-25 09:40:16 UTC (rev 128144)
@@ -106,19 +106,34 @@
 override files are a good place to ensure this.
 
 It can also be conveniend to unconfigure an entire zcml file. This can
-be done by using an include statement inside an unconfigure block:
+be done without using z3c.unconfigure, if you use the ``<exclude />``
+directive before you include that file:
 
   >>> zcml("""
   ... <configure>
+  ...   <exclude file="lolcat.zcml" />
   ...   <print msg="The new hello" />
   ...   <include file="lolcat.zcml" />
   ...   <include package="z3c.unconfigure" file="meta.zcml" />
+  ...   <print msg="The final goodbye" />
+  ... </configure>
+  ... """)
+  The new hello
+  The final goodbye
+
+Or you can try to use an include statement inside an unconfigure block:
+
+  >>> zcml("""
+  ... <configure>
+  ...   <print msg="The new hello" />
+  ...   <include file="lolcat.zcml" />
+  ...   <include package="z3c.unconfigure" file="meta.zcml" />
   ...   <unconfigure>
   ...     <include file="lolcat.zcml" />
   ...   </unconfigure>
   ...   <print msg="The final goodbye" />
   ... </configure>
-  ... """)  # XXX this is currently broken, so the test fails
+  ... """)
   The new hello
   The final goodbye
 

Modified: z3c.unconfigure/trunk/src/z3c/unconfigure/config.py
===================================================================
--- z3c.unconfigure/trunk/src/z3c/unconfigure/config.py	2012-10-25 09:32:02 UTC (rev 128143)
+++ z3c.unconfigure/trunk/src/z3c/unconfigure/config.py	2012-10-25 09:40:16 UTC (rev 128144)
@@ -66,6 +66,12 @@
         # all actions within 'unconfigure' will be added to this list
         # here, not the global actions list.
         self.actions = []
+        # The same logic applies to _seen_files.  It's normally used to
+        # avoid configuration conflicts by ignoring duplicated <include/>
+        # directives, but in this case we don't want to ignore an <include/>
+        # placed inside an <unconfigure> group that tries to undo a previous
+        # <include/>.
+        self._seen_files = set()
 
     def after(self):
         # Get a discriminator -> action representation of all the



More information about the checkins mailing list