ia64/xen-unstable

changeset 6946:e703abaf6e3d

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.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents da5e4c8a0fea
children 7e8eac6e96c6
files tools/python/xen/xend/xenstore/xstransact.py
line diff
     1.1 --- a/tools/python/xen/xend/xenstore/xstransact.py	Sun Sep 18 10:09:22 2005 +0100
     1.2 +++ b/tools/python/xen/xend/xenstore/xstransact.py	Sun Sep 18 14:42:13 2005 +0100
     1.3 @@ -89,10 +89,15 @@ class xstransact:
     1.4          return xshandle().rm(path)
     1.5  
     1.6      def remove(self, *args):
     1.7 +        """If no arguments are given, remove this transaction's path.
     1.8 +        Otherwise, treat each argument as a subpath to this transaction's
     1.9 +        path, and remove each of those instead.
    1.10 +        """
    1.11          if len(args) == 0:
    1.12 -            raise TypeError
    1.13 -        for key in args:
    1.14 -            self._remove(key)
    1.15 +            xshandle().rm(self.path)
    1.16 +        else:
    1.17 +            for key in args:
    1.18 +                self._remove(key)
    1.19  
    1.20      def _list(self, key):
    1.21          path = "%s/%s" % (self.path, key)
    1.22 @@ -188,6 +193,10 @@ class xstransact:
    1.23      Write = classmethod(Write)
    1.24  
    1.25      def Remove(cls, path, *args):
    1.26 +        """If only one argument is given (path), remove it.  Otherwise, treat
    1.27 +        each further argument as a subpath to the given path, and remove each
    1.28 +        of those instead.  This operation is performed inside a transaction.
    1.29 +        """
    1.30          while True:
    1.31              t = cls(path)
    1.32              try: