[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.



# HG changeset patch
# User emellor@ewan
# Node ID e703abaf6e3de653089d10f660c6fee49df0c434
# Parent  da5e4c8a0fea3f8e452fc9e3fe7dbb31776bd4e7
Add behaviour to the remove methods to remove the transaction's path itself.  
This allows us to write Remove(path) to remove the specified path rather than 
having to slice the path ourselves.

diff -r da5e4c8a0fea -r e703abaf6e3d 
tools/python/xen/xend/xenstore/xstransact.py
--- a/tools/python/xen/xend/xenstore/xstransact.py      Sun Sep 18 09:09:22 2005
+++ b/tools/python/xen/xend/xenstore/xstransact.py      Sun Sep 18 13:42:13 2005
@@ -89,10 +89,15 @@
         return xshandle().rm(path)
 
     def remove(self, *args):
-        if len(args) == 0:
-            raise TypeError
-        for key in args:
-            self._remove(key)
+        """If no arguments are given, remove this transaction's path.
+        Otherwise, treat each argument as a subpath to this transaction's
+        path, and remove each of those instead.
+        """
+        if len(args) == 0:
+            xshandle().rm(self.path)
+        else:
+            for key in args:
+                self._remove(key)
 
     def _list(self, key):
         path = "%s/%s" % (self.path, key)
@@ -188,6 +193,10 @@
     Write = classmethod(Write)
 
     def Remove(cls, path, *args):
+        """If only one argument is given (path), remove it.  Otherwise, treat
+        each further argument as a subpath to the given path, and remove each
+        of those instead.  This operation is performed inside a transaction.
+        """
         while True:
             t = cls(path)
             try:

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.