ia64/xen-unstable

changeset 7089:a65cdee92c0f

Added behaviour to read() to read directly from the transaction's path if no
arguments are specified.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Wed Sep 28 13:43:07 2005 +0100 (2005-09-28)
parents 1e288a9316fd
children d78d2fa50703
files tools/python/xen/xend/xenstore/xstransact.py
line diff
     1.1 --- a/tools/python/xen/xend/xenstore/xstransact.py	Wed Sep 28 13:41:44 2005 +0100
     1.2 +++ b/tools/python/xen/xend/xenstore/xstransact.py	Wed Sep 28 13:43:07 2005 +0100
     1.3 @@ -42,8 +42,15 @@ class xstransact:
     1.4                                 '%s, while reading %s' % (ex.args[1], path))
     1.5  
     1.6      def read(self, *args):
     1.7 +        """If no arguments are given, return the value at this transaction's
     1.8 +        path.  If one argument is given, treat that argument as a subpath to
     1.9 +        this transaction's path, and return the value at that path.
    1.10 +        Otherwise, treat each argument as a subpath to this transaction's
    1.11 +        path, and return a list composed of the values at each of those
    1.12 +        instead.
    1.13 +        """
    1.14          if len(args) == 0:
    1.15 -            raise TypeError
    1.16 +            return xshandle().read(self.path)
    1.17          if len(args) == 1:
    1.18              return self._read(args[0])
    1.19          ret = []
    1.20 @@ -191,6 +198,13 @@ class xstransact:
    1.21  
    1.22  
    1.23      def Read(cls, path, *args):
    1.24 +        """If only one argument is given (path), return the value stored at
    1.25 +        that path.  If two arguments are given, treat the second argument as a
    1.26 +        subpath within the first, and return the value at the composed path.
    1.27 +        Otherwise, treat each argument after the first as a subpath to the
    1.28 +        given path, and return a list composed of the values at each of those
    1.29 +        instead.  This operation is performed inside a transaction.
    1.30 +        """
    1.31          while True:
    1.32              t = cls(path)
    1.33              try:
    1.34 @@ -234,6 +248,12 @@ class xstransact:
    1.35      Remove = classmethod(Remove)
    1.36  
    1.37      def List(cls, path, *args):
    1.38 +        """If no arguments are given (path), list its contents, returning the
    1.39 +        entries therein, or None if no entries are found.  Otherwise, treat
    1.40 +        each further argument as a subpath to the given path, and return the
    1.41 +        cumulative listing of each of those instead.  This operation is
    1.42 +        performed inside a transaction.
    1.43 +        """
    1.44          while True:
    1.45              t = cls(path)
    1.46              try: