[CalendarServer-changes] [8268] CalendarServer/trunk/calendarserver/tools/shell.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Nov 9 13:11:30 PST 2011


Revision: 8268
          http://trac.macosforge.org/projects/calendarserver/changeset/8268
Author:   wsanchez at apple.com
Date:     2011-11-09 13:11:30 -0800 (Wed, 09 Nov 2011)
Log Message:
-----------
list() should defer. UIDDirectory.subdir() works.

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/shell.py

Modified: CalendarServer/trunk/calendarserver/tools/shell.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell.py	2011-11-09 00:39:20 UTC (rev 8267)
+++ CalendarServer/trunk/calendarserver/tools/shell.py	2011-11-09 21:11:30 UTC (rev 8268)
@@ -284,9 +284,19 @@
             raise UnknownArguments(tokens)
             return
 
-        for name in self.wd.list():
-            self.terminal.write("%s\n" % (name,))
+        def write(names):
+            #
+            # FIXME: this can be ugly if, for example, there are
+            # zillions of calendar homes or events to output. Paging
+            # would be good.
+            #
+            for name in names:
+                self.terminal.write("%s\n" % (name,))
 
+        d = self.wd.list()
+        d.addCallback(write)
+        return d
+
     def cmd_info(self, tokens):
         """
         Print information about working directory.
@@ -376,7 +386,7 @@
         return fail(NotFoundError("Directory %r has no subdirectory %r" % (str(self), name)))
 
     def list(self):
-        return ()
+        return succeed(())
 
 
 class RootDirectory(Directory):
@@ -403,7 +413,7 @@
         return Directory.subdir(self, name)
 
     def list(self):
-        return ("%s/" % (n,) for n in self._childClasses)
+        return succeed(("%s/" % (n,) for n in self._childClasses))
 
 
 class UIDDirectory(Directory):
@@ -414,18 +424,20 @@
         txn = self.store.newTransaction()
 
         def gotHome(home):
-            if home:
-                return HomeDirectory(self.store, self.path + (name,), home)
+            if not home:
+                return fail(NotFoundError("No calendar home for UID %r" % (name,)))
 
-            return Directory.subdir(self, name)
+            return HomeDirectory(self.store, self.path + (name,), home)
 
         d = txn.calendarHomeWithUID(name)
         d.addCallback(gotHome)
         return d
 
     def list(self):
-        for (txn, home) in self.store.eachCalendarHome():
-            yield home.uid()
+        raise NotImplementedError("UIDDirectory.list() isn't implemented.")
+        d = self.store.eachCalendarHome()
+        d.addCallback(lambda homes: (home.uid() for (txn, home) in homes))
+        return d
 
 
 class HomeDirectory(Directory):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111109/51aba323/attachment.html>


More information about the calendarserver-changes mailing list