[Checkins] SVN: zc.zk/trunk/src/zc/zk/ Change the import_tree method to provide a way to suppress warnings

jim cvs-admin at zope.org
Wed Nov 7 17:09:10 UTC 2012


Log message for revision 128189:
  Change the import_tree method to provide a way to suppress warnings
  about not trimming nodes using ``trim=False``.
  

Changed:
  U   zc.zk/trunk/src/zc/zk/README.txt
  U   zc.zk/trunk/src/zc/zk/__init__.py

-=-
Modified: zc.zk/trunk/src/zc/zk/README.txt
===================================================================
--- zc.zk/trunk/src/zc/zk/README.txt	2012-11-07 13:18:23 UTC (rev 128188)
+++ zc.zk/trunk/src/zc/zk/README.txt	2012-11-07 17:09:09 UTC (rev 128189)
@@ -353,8 +353,18 @@
     >>> zk.import_tree(tree_text, trim=True, dry_run=True)
     would delete /lb/pools/retail.
 
-That's what we'd expect, so we go ahead::
+If we know we're not trimming things and want to avoid a warning, we
+can use trim=False:
 
+    >>> zk.import_tree(tree_text, trim=False)
+
+We can see that this didn't trim by using dry-run again:
+
+    >>> zk.import_tree(tree_text, trim=True, dry_run=True)
+    would delete /lb/pools/retail.
+
+We do want to trim, so we use trim=True:
+
     >>> zk.import_tree(tree_text, trim=True)
     >>> print zk.export_tree(),
     /cms : z4m cms
@@ -1203,6 +1213,12 @@
 Change History
 ==============
 
+1.1.0 (2012-11-07)
+------------------
+
+- Change the import_tree method to provide a way to suppress warnings
+  about not trimming nodes using ``trim=False``.
+
 1.0.0 (2012-09-25)
 ------------------
 

Modified: zc.zk/trunk/src/zc/zk/__init__.py
===================================================================
--- zc.zk/trunk/src/zc/zk/__init__.py	2012-11-07 13:18:23 UTC (rev 128188)
+++ zc.zk/trunk/src/zc/zk/__init__.py	2012-11-07 17:09:09 UTC (rev 128189)
@@ -402,7 +402,7 @@
     def properties(self, path):
         return Properties(self, path)
 
-    def import_tree(self, text, path='/', trim=False, acl=OPEN_ACL_UNSAFE,
+    def import_tree(self, text, path='/', trim=None, acl=OPEN_ACL_UNSAFE,
                     dry_run=False):
         while path.endswith('/'):
             path = path[:-1] # Mainly to deal w root: /
@@ -418,7 +418,7 @@
                 if trim:
                     self.delete_recursive(cpath, dry_run,
                                           ignore_if_ephemeral=True)
-                else:
+                elif trim is None:
                     print 'extra path not trimmed:', cpath
 
         for name, child in sorted(node.children.iteritems()):



More information about the checkins mailing list