[CalendarServer-changes] [5066] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Mon Feb 8 17:01:58 PST 2010
Revision: 5066
http://trac.macosforge.org/projects/calendarserver/changeset/5066
Author: wsanchez at apple.com
Date: 2010-02-08 17:01:57 -0800 (Mon, 08 Feb 2010)
Log Message:
-----------
Move janky Index glue to its own class
Modified Paths:
--------------
CalendarServer/trunk/support/submit
CalendarServer/trunk/txcaldav/calendarstore/file.py
CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py
CalendarServer/trunk/txcaldav/icalendarstore.py
Modified: CalendarServer/trunk/support/submit
===================================================================
--- CalendarServer/trunk/support/submit 2010-02-09 01:01:19 UTC (rev 5065)
+++ CalendarServer/trunk/support/submit 2010-02-09 01:01:57 UTC (rev 5066)
@@ -176,7 +176,6 @@
sudo ~rc/bin/buildit "${wc}" CALENDARSERVER_CACHE_DEPS="${CALENDARSERVER_CACHE_DEPS-${wd}/.dependencies}" \
$(file /System/Library/Frameworks/Python.framework/Versions/Current/Python | sed -n -e 's|^.*(for architecture \([^)][^)]*\).*$|-arch \1|p' | sed 's|ppc7400|ppc|') \
- -release SnowLeopard \
${merge_flags};
if "${package}"; then
Modified: CalendarServer/trunk/txcaldav/calendarstore/file.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/file.py 2010-02-09 01:01:19 UTC (rev 5065)
+++ CalendarServer/trunk/txcaldav/calendarstore/file.py 2010-02-09 01:01:57 UTC (rev 5066)
@@ -30,7 +30,7 @@
from zope.interface import implements
from twisted.python.filepath import FilePath
-from twisted.internet.defer import inlineCallbacks, returnValue
+from twisted.internet.defer import inlineCallbacks
from twext.log import LoggingMixIn
from twext.python.icalendar import Component as iComponent
@@ -49,7 +49,7 @@
from txcaldav.icalendarstore import InvalidCalendarComponentError
from txcaldav.icalendarstore import InternalDataStoreError
-from twistedcaldav.index import Index
+from twistedcaldav.index import Index as OldIndex
from twistedcaldav.memcachelock import MemcacheLock, MemcacheLockTimeoutError
@@ -162,40 +162,8 @@
return "<%s: %s>" % (self.__class__.__name__, self.path.path)
def index(self):
- #
- # OK, here's where we get ugly.
- # The index code needs to be rewritten also, but in the meantime...
- #
- class StubResource(object):
- """
- Just enough resource to keep the Index class going.
- """
- def __init__(self, calendar):
- self.calendar = calendar
- self.fp = self.calendar.path
-
- def isCalendarCollection(self):
- return True
-
- def getChild(self, name):
- calendarObject = self.calendar.calendarObjectWithName(name)
- if calendarObject:
- class ChildResource(object):
- def __init__(self, calendarObject):
- self.calendarObject = calendarObject
-
- def iCalendar(self):
- return self.calendarObject.component()
-
- return ChildResource(calendarObject)
- else:
- return None
-
- def bumpSyncToken(self, reset=False):
- return self.calendar._updateSyncToken(reset)
-
if not hasattr(self, "_index"):
- self._index = Index(StubResource(self))
+ self._index = Index(self)
return self._index
def name(self):
@@ -205,15 +173,8 @@
return self.calendarHome
def _calendarObjects_index(self):
- for name, uid, componentType in self.index().bruteForceSearch():
- calendarObject = self.calendarObjectWithName(name)
+ return self.index().calendarObjects()
- # Precache what we found in the index
- calendarObject._uid = uid
- calendarObject._componentType = componentType
-
- yield calendarObject
-
def _calendarObjects_listdir(self):
return (
self.calendarObjectWithName(name)
@@ -221,8 +182,7 @@
if not name.startswith(".")
)
- calendarObjects = _calendarObjects_listdir
- #calendarObjects = _calendarObjects_index
+ calendarObjects = _calendarObjects_index
def calendarObjectWithName(self, name):
childPath = self.path.child(name)
@@ -278,7 +238,7 @@
if reset:
token = newToken()
- raise NotImplementedError()
+ raise NotImplementedError(token)
finally:
yield lock.clean()
@@ -409,3 +369,52 @@
if not hasattr(self, "_properties"):
self._properties = PropertyStore(self.path)
return self._properties
+
+class Index (object):
+ #
+ # OK, here's where we get ugly.
+ # The index code needs to be rewritten also, but in the meantime...
+ #
+ class StubResource(object):
+ """
+ Just enough resource to keep the Index class going.
+ """
+ def __init__(self, calendar):
+ self.calendar = calendar
+ self.fp = self.calendar.path
+
+ def isCalendarCollection(self):
+ return True
+
+ def getChild(self, name):
+ calendarObject = self.calendar.calendarObjectWithName(name)
+ if calendarObject:
+ class ChildResource(object):
+ def __init__(self, calendarObject):
+ self.calendarObject = calendarObject
+
+ def iCalendar(self):
+ return self.calendarObject.component()
+
+ return ChildResource(calendarObject)
+ else:
+ return None
+
+ def bumpSyncToken(self, reset=False):
+ return self.calendar._updateSyncToken(reset)
+
+
+ def __init__(self, calendar):
+ self.calendar = calendar
+ self._oldIndex = OldIndex(Index.StubResource(calendar))
+
+ def calendarObjects(self):
+ calendar = self.calendar
+ for name, uid, componentType in self._oldIndex.bruteForceSearch():
+ calendarObject = calendar.calendarObjectWithName(name)
+
+ # Precache what we found in the index
+ calendarObject._uid = uid
+ calendarObject._componentType = componentType
+
+ yield calendarObject
Modified: CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py
===================================================================
--- CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py 2010-02-09 01:01:19 UTC (rev 5065)
+++ CalendarServer/trunk/txcaldav/calendarstore/test/test_file.py 2010-02-09 01:01:57 UTC (rev 5066)
@@ -125,13 +125,13 @@
)
-def featureUnimplemented(f):
- f.todo = "Feature Unimplemented"
+def _todo(f, why):
+ f.todo = why
return f
-def testUnimplemented(f):
- f.todo = "Test Unimplemented"
- return f
+featureUnimplemented = lambda f: _todo(f, "Feature unimplemented")
+testUnimplemented = lambda f: _todo(f, "Test unimplemented")
+todo = lambda why: lambda f: _todo(f, why)
class PropertiesTestMixin(object):
@@ -387,14 +387,13 @@
self.home1.uid()
)
- def test_calendarObjects(self):
- """
- Find all of the calendar objects.
- """
+ def _test_calendarObjects(self, which):
# Add a dot file to make sure we don't find it
self.home1.path.child(".foo").createDirectory()
- calendarObjects = tuple(self.calendar1.calendarObjects())
+ methodName = "_calendarObjects_%s" % (which,)
+ method = getattr(self.calendar1, methodName)
+ calendarObjects = tuple(method())
for calendarObject in calendarObjects:
self.failUnless(
@@ -407,6 +406,21 @@
calendar1_objectNames
)
+ def test_calendarObjects_listdir(self):
+ """
+ Find all of the calendar objects using the listdir
+ implementation.
+ """
+ return self._test_calendarObjects("listdir")
+
+ @todo("Index is missing 1.ics?")
+ def test_calendarObjects_index(self):
+ """
+ Find all of the calendar objects using the index
+ implementation.
+ """
+ return self._test_calendarObjects("index")
+
def test_calendarObjectWithName_exists(self):
"""
Find existing calendar object by name.
@@ -505,6 +519,7 @@
self.calendar1.createCalendarObjectWithName,
name, component
)
+
def test_createCalendarObjectWithName_invalid(self):
"""
Attempt to create a calendar object with a invalid iCalendar text
Modified: CalendarServer/trunk/txcaldav/icalendarstore.py
===================================================================
--- CalendarServer/trunk/txcaldav/icalendarstore.py 2010-02-09 01:01:19 UTC (rev 5065)
+++ CalendarServer/trunk/txcaldav/icalendarstore.py 2010-02-09 01:01:57 UTC (rev 5066)
@@ -18,6 +18,10 @@
Calendar store interfaces
"""
+# FIXME: Still to do:
+# - Where to defer?
+# - commit() and abort()
+
__all__ = [
# Exceptions
"CalendarStoreError",
@@ -32,7 +36,6 @@
"NoSuchCalendarError",
"NoSuchCalendarObjectError",
"InvalidCalendarComponentError",
- "TryAgainLaterError",
"InternalDataStoreError",
# Classes
@@ -111,11 +114,6 @@
Invalid calendar component.
"""
-class TryAgainLaterError(CalendarStoreError):
- """
- Requested resource is in use. Try again later.
- """
-
class InternalDataStoreError(CalendarStoreError):
"""
Uh, oh.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100208/91671d4f/attachment-0001.html>
More information about the calendarserver-changes
mailing list