[CalendarServer-changes] [5295] CalendarServer/trunk/txcaldav/calendarstore
source_changes at macosforge.org
source_changes at macosforge.org
Fri Mar 12 12:13:29 PST 2010
Revision: 5295
http://trac.macosforge.org/projects/calendarserver/changeset/5295
Author: wsanchez at apple.com
Date: 2010-03-12 12:13:29 -0800 (Fri, 12 Mar 2010)
Log Message:
-----------
Match the existing file system layout with the 2-char prefixes (ho/me/home1/ instead of just home1/).
Advertise ICalendarStore compliance.
Add create kwarg to calendarHomeWithUID().
Modified Paths:
--------------
CalendarServer/trunk/txcaldav/calendarstore/file.py
CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py
Added Paths:
-----------
CalendarServer/trunk/txcaldav/calendarstore/test/calendar_store/ho/
CalendarServer/trunk/txcaldav/calendarstore/test/calendar_store/ho/me/
CalendarServer/trunk/txcaldav/calendarstore/test/calendar_store/ho/me/home1/
Removed Paths:
-------------
CalendarServer/trunk/txcaldav/calendarstore/test/calendar_store/home1/
Modified: CalendarServer/trunk/txcaldav/calendarstore/file.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/file.py 2010-03-12 20:11:42 UTC (rev 5294)
+++ CalendarServer/trunk/txcaldav/calendarstore/file.py 2010-03-12 20:13:29 UTC (rev 5295)
@@ -38,7 +38,8 @@
from txdav.propertystore.xattr import PropertyStore
-from txcaldav.icalendarstore import ICalendarHome, ICalendar, ICalendarObject
+from txcaldav.icalendarstore import ICalendarStore, ICalendarHome
+from txcaldav.icalendarstore import ICalendar, ICalendarObject
from txcaldav.icalendarstore import CalendarNameNotAllowedError
from txcaldav.icalendarstore import CalendarObjectNameNotAllowedError
from txcaldav.icalendarstore import CalendarAlreadyExistsError
@@ -54,7 +55,7 @@
class CalendarStore(LoggingMixIn):
- # FIXME: Do we need an interface?
+ implements(ICalendarStore)
calendarHomeClass = property(lambda _: CalendarHome)
@@ -67,25 +68,29 @@
self.path = path
if not path.isdir():
- # FIXME: If we add a CalendarStore interface, this should
- # be CalendarStoreNotFoundError.
+ # FIXME: Add CalendarStoreNotFoundError?
raise NotFoundError("No such calendar store")
def __repr__(self):
return "<%s: %s>" % (self.__class__.__name__, self.path.path)
- def calendarHomeWithUID(self, uid):
+ def calendarHomeWithUID(self, uid, create=False):
if uid.startswith("."):
return None
- childPath = self.path.child(uid)
+ assert len(uid) >= 4
- if childPath.isdir():
- return CalendarHome(childPath, self)
- else:
- return None
+ childPath = self.path.child(uid[0:2]).child(uid[2:4]).child(uid)
+ if not childPath.isdir():
+ if create:
+ childPath.makedirs()
+ else:
+ return None
+ return CalendarHome(childPath, self)
+
+
class CalendarHome(LoggingMixIn):
implements(ICalendarHome)
@@ -370,6 +375,7 @@
self._properties = PropertyStore(self.path)
return self._properties
+
class Index (object):
#
# OK, here's where we get ugly.
Modified: CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py 2010-03-12 20:11:42 UTC (rev 5294)
+++ CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py 2010-03-12 20:13:29 UTC (rev 5295)
@@ -152,14 +152,17 @@
storePath.copyTo(calendarPath)
test.calendarStore = CalendarStore(calendarPath)
+ assert test.calendarStore is not None, "No calendar store?"
def setUpHome1(test):
setUpCalendarStore(test)
test.home1 = test.calendarStore.calendarHomeWithUID("home1")
+ assert test.home1 is not None, "No calendar home?"
def setUpCalendar1(test):
setUpHome1(test)
test.calendar1 = test.home1.calendarWithName("calendar_1")
+ assert test.calendar1 is not None, "No calendar?"
class CalendarStoreTest(unittest.TestCase):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100312/f66b3c2b/attachment-0001.html>
More information about the calendarserver-changes
mailing list