[Checkins] SVN: zc.zk/trunk/src/zc/zk/ - Fixed: When importing a tree with no changes and the trim option,
jim
cvs-admin at zope.org
Fri Aug 31 20:20:54 UTC 2012
Log message for revision 127662:
- Fixed: When importing a tree with no changes and the trim option,
messages were printed for ephemeral nodes.
Changed:
U zc.zk/trunk/src/zc/zk/README.txt
U zc.zk/trunk/src/zc/zk/__init__.py
U zc.zk/trunk/src/zc/zk/tests.py
-=-
Modified: zc.zk/trunk/src/zc/zk/README.txt
===================================================================
--- zc.zk/trunk/src/zc/zk/README.txt 2012-08-31 19:19:22 UTC (rev 127661)
+++ zc.zk/trunk/src/zc/zk/README.txt 2012-08-31 20:20:51 UTC (rev 127662)
@@ -959,13 +959,20 @@
This should be called when cleanly shutting down servers to more
quickly remove ephemeral nodes.
-``delete_recursive(path[, dry_run[, force]])``
+``delete_recursive(path[, dry_run[, force[, ignore_if_ephemeral]]])``
Delete a node and all of it's sub-nodes.
Ephemeral nodes or nodes containing them are not deleted by
default. To force deletion of ephemeral nodes, supply the ``force``
option with a true value.
+ Normally, a message is printed if a node can't be deleted because
+ it's ephemeral or has ephemeral sub-nodes. If the
+ ``ignore_if_ephemeral`` option is true, the a message isn't printed
+ if the node's path was passed to ``delete_recursive`` directly.
+ (This is used by ``import_tree`` when the only nodes that would be
+ trimmed are ephemeral nodes.)
+
The dry_run option causes a summary of what would be deleted to be
printed without actually deleting anything.
@@ -1169,7 +1176,7 @@
==============
-0.9.2 (2012-??-??)
+0.9.2 (2012-08-31)
------------------
- Fixed: The documentation for get_properties was missleading.
@@ -1178,6 +1185,9 @@
Iteration and methods keys, values, and items weren't handled
correctly.
+- Fixed: When importing a tree with no changes and the trim option,
+ messages were printed for ephemeral nodes.
+
0.9.2 (2012-08-08)
------------------
Modified: zc.zk/trunk/src/zc/zk/__init__.py
===================================================================
--- zc.zk/trunk/src/zc/zk/__init__.py 2012-08-31 19:19:22 UTC (rev 127661)
+++ zc.zk/trunk/src/zc/zk/__init__.py 2012-08-31 20:20:51 UTC (rev 127662)
@@ -416,7 +416,8 @@
continue
cpath = join(path, name)
if trim:
- self.delete_recursive(cpath, dry_run)
+ self.delete_recursive(cpath, dry_run,
+ ignore_if_ephemeral=True)
else:
print 'extra path not trimmed:', cpath
@@ -462,10 +463,12 @@
self.create(cpath, data, acl)
self._import_tree(cpath, child, acl, trim, dry_run)
- def delete_recursive(self, path, dry_run=False, force=False):
- self._delete_recursive(path, dry_run, force)
+ def delete_recursive(self, path, dry_run=False, force=False,
+ ignore_if_ephemeral=False):
+ self._delete_recursive(path, dry_run, force, ignore_if_ephemeral)
- def _delete_recursive(self, path, dry_run, force):
+ def _delete_recursive(self, path, dry_run, force,
+ ignore_if_ephemeral=False):
ephemeral_child = None
for name in sorted(self.get_children(path)):
ephemeral_child = (
@@ -478,6 +481,8 @@
return ephemeral_child
ephemeral = self.is_ephemeral(path) and not force
+ if ephemeral and ignore_if_ephemeral:
+ return
if dry_run:
if ephemeral:
print "wouldn't delete %s because it's ephemeral." % path
Modified: zc.zk/trunk/src/zc/zk/tests.py
===================================================================
--- zc.zk/trunk/src/zc/zk/tests.py 2012-08-31 19:19:22 UTC (rev 127661)
+++ zc.zk/trunk/src/zc/zk/tests.py 2012-08-31 20:20:51 UTC (rev 127662)
@@ -1502,7 +1502,6 @@
def property_links_edge_cases():
"""
-
>>> zk = zc.zk.ZooKeeper('zookeeper.example.com:2181')
>>> zk.import_tree('''
... /app
@@ -1536,9 +1535,41 @@
>>> pprint(dict(properties))
{u'color': u'red', u'database ->': u'/databases/foo', u'threads': 1}
+
+ >>> zk.close()
"""
+def no_spam_when_not_trimming_ephemeral_nodes():
+ """
+ >>> zk = zc.zk.ZooKeeper('zookeeper.example.com:2181')
+ >>> zk.print_tree()
+ /fooservice
+ database = u'/databases/foomain'
+ favorite_color = u'red'
+ threads = 1
+ /providers
+ >>> zk.register_server('/fooservice/providers', 'a:a')
+ >>> zk.print_tree()
+ /fooservice
+ database = u'/databases/foomain'
+ favorite_color = u'red'
+ threads = 1
+ /providers
+ /a:a
+ pid = 1234
+
+ >>> zk.import_tree('''
+ ... /fooservice
+ ... database = u'/databases/foomain'
+ ... favorite_color = u'red'
+ ... threads = 1
+ ... /providers
+ ... ''', trim=True)
+
+ >>> zk.close()
+ """
+
event = threading.Event()
def check_async(show=True, expected_status=0):
event.clear()
More information about the checkins
mailing list