WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Added new classmethod xstransact.ListRecursive, and use

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Added new classmethod xstransact.ListRecursive, and use this inside
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 28 Sep 2005 14:16:14 +0000
Delivery-date: Wed, 28 Sep 2005 14:14:14 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User emellor@ewan
# Node ID ca78d9668fdbb90ef116f6fe90b4ebef9eee2b35
# Parent  1d74fff611c80eedbd1b4b22ba59177f933b5063
Added new classmethod xstransact.ListRecursive, and use this inside
DevController to tidy up the code there.  Change the semantics of
xstransact.list and List to return the empty list rather than None if there
are no entries or the directory is not present, as this is easier to handle
for the client.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r 1d74fff611c8 -r ca78d9668fdb 
tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py     Wed Sep 28 14:03:27 2005
+++ b/tools/python/xen/xend/server/DevController.py     Wed Sep 28 14:06:48 2005
@@ -85,16 +85,7 @@
         """@return an s-expression describing all the devices of this
         controller's device-class.
         """
-        path = self.frontendRoot()
-        while True:
-            t = xstransact(path)
-            try:
-                listing = t.list_recursive()
-                if t.commit():
-                    return listing
-            except:
-                t.abort()
-                raise
+        return xstransact.ListRecursive(self.frontendRoot())
 
 
     def sxpr(self, devid):
diff -r 1d74fff611c8 -r ca78d9668fdb 
tools/python/xen/xend/xenstore/xstransact.py
--- a/tools/python/xen/xend/xenstore/xstransact.py      Wed Sep 28 14:03:27 2005
+++ b/tools/python/xen/xend/xenstore/xstransact.py      Wed Sep 28 14:06:48 2005
@@ -115,12 +115,16 @@
 
     def list(self, *args):
         """If no arguments are given, list this transaction's path, returning
-        the entries therein, or None if no entries are found.  Otherwise,
-        treat each argument as a subpath to this transaction's path, and
-        return the cumulative listing of each of those instead.
-        """
-        if len(args) == 0:
-            return xshandle().ls(self.path)
+        the entries therein, or the empty list if no entries are found.
+        Otherwise, treat each argument as a subpath to this transaction's
+        path, and return the cumulative listing of each of those instead.
+        """
+        if len(args) == 0:
+            ret = xshandle().ls(self.path)
+            if ret is None:
+                return []
+            else:
+                return ret
         else:
             ret = []
             for key in args:
@@ -141,8 +145,15 @@
 
 
     def list_recursive(self, *args):
+        """If no arguments are given, list this transaction's path, returning
+        the entries therein, or the empty list if no entries are found.
+        Otherwise, treat each argument as a subpath to this transaction's
+        path, and return the cumulative listing of each of those instead.
+        """
         if len(args) == 0:
             args = self.list()
+            if args is None or len(args) == 0:
+                return []
 
         return self.list_recursive_(self.path, args)
 
@@ -248,11 +259,11 @@
     Remove = classmethod(Remove)
 
     def List(cls, path, *args):
-        """If no arguments are given (path), list its contents, returning the
-        entries therein, or None if no entries are found.  Otherwise, treat
-        each further argument as a subpath to the given path, and return the
-        cumulative listing of each of those instead.  This operation is
-        performed inside a transaction.
+        """If only one argument is given (path), list its contents, returning
+        the entries therein, or the empty list if no entries are found.
+        Otherwise, treat each further argument as a subpath to the given path,
+        and return the cumulative listing of each of those instead.  This
+        operation is performed inside a transaction.
         """
         while True:
             t = cls(path)
@@ -266,6 +277,25 @@
 
     List = classmethod(List)
 
+    def ListRecursive(cls, path, *args):
+        """If only one argument is given (path), list its contents
+        recursively, returning the entries therein, or the empty list if no
+        entries are found.  Otherwise, treat each further argument as a
+        subpath to the given path, and return the cumulative listing of each
+        of those instead.  This operation is performed inside a transaction.
+        """
+        while True:
+            t = cls(path)
+            try:
+                v = t.list_recursive(*args)
+                if t.commit():
+                    return v
+            except:
+                t.abort()
+                raise
+
+    ListRecursive = classmethod(ListRecursive)
+
     def Gather(cls, path, *args):
         while True:
             t = cls(path)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Added new classmethod xstransact.ListRecursive, and use this inside, Xen patchbot -unstable <=