[CalendarServer-changes] [5565] CalendarServer/branches/users/wsanchez/transations/txcaldav/ calendarstore
source_changes at macosforge.org
source_changes at macosforge.org
Tue May 4 17:02:58 PDT 2010
Revision: 5565
http://trac.macosforge.org/projects/calendarserver/changeset/5565
Author: glyph at apple.com
Date: 2010-05-04 17:02:56 -0700 (Tue, 04 May 2010)
Log Message:
-----------
Store properties indicating resource type. (Necessary for filesystem-level compatibility. We should only need this in the filesystem backend.)
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/transations/txcaldav/calendarstore/file.py
CalendarServer/branches/users/wsanchez/transations/txcaldav/calendarstore/test/test_file.py
Modified: CalendarServer/branches/users/wsanchez/transations/txcaldav/calendarstore/file.py
===================================================================
--- CalendarServer/branches/users/wsanchez/transations/txcaldav/calendarstore/file.py 2010-05-05 00:00:59 UTC (rev 5564)
+++ CalendarServer/branches/users/wsanchez/transations/txcaldav/calendarstore/file.py 2010-05-05 00:02:56 UTC (rev 5565)
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
##
+from twext.web2.dav.element.rfc2518 import ResourceType
+from txdav.propertystore.base import PropertyName
"""
File calendar store.
@@ -79,9 +81,9 @@
self.thunk = thunk
- def __get__(self, oself, name):
+ def __get__(self, oself, owner):
def inner():
- cacheKey = "_"+name+"_cached"
+ cacheKey = "_" + self.thunk.__name__ + "_cached"
cached = getattr(oself, cacheKey, _unset)
if cached is _unset:
value = self.thunk(oself)
@@ -217,6 +219,7 @@
return calendarHome
+
class CalendarHome(LoggingMixIn):
implements(ICalendarHome)
@@ -277,7 +280,15 @@
raise
self._transaction.addOperation(do)
- self._newCalendars[name] = Calendar(self._path.child(name), self)
+ c = self._newCalendars[name] = Calendar(self._path.child(name), self)
+ c.properties()[PropertyName.fromString(ResourceType.sname())] = \
+ ResourceType.calendar
+ # FIXME: there's no need for 'flush' to be a public method of the
+ # property store any more. It should just be transactional like
+ # everything else; the API here would better be expressed as
+ # c.properties().participateInTxn(txn)
+ self._transaction.addOperation(c.properties().flush)
+ # FIXME: return c # maybe ?
def removeCalendarWithName(self, name):
if name.startswith(".") or name in self._removedCalendars:
@@ -316,6 +327,7 @@
return undo
+
def properties(self):
# FIXME: needs tests for actual functionality
# FIXME: needs to be cached
@@ -364,7 +376,7 @@
return (
self.calendarObjectWithName(name)
for name in (
- set(self._newCalendarObjects.iterkeys()) |
+ set(self._newCalendarObjects.iterkeys()) |
set(name for name in self._path.listdir() if not name.startswith("."))
)
)
@@ -461,10 +473,12 @@
def calendarObjectsSinceToken(self, token):
raise NotImplementedError()
+
+ @_cached
def properties(self):
- # FIXME: needs tests
- # FIXME: needs implementation
- raise NotImplementedError()
+ # FIXME: needs direct tests - only covered by calendar store tests
+ # FIXME: transactions
+ return PropertyStore(self._path)
@@ -492,7 +506,7 @@
def setComponent(self, component):
if not isinstance(component, VComponent):
- raise TypeError(VComponent)
+ raise TypeError(type(component))
try:
if component.resourceUID() != self.uid():
Modified: CalendarServer/branches/users/wsanchez/transations/txcaldav/calendarstore/test/test_file.py
===================================================================
--- CalendarServer/branches/users/wsanchez/transations/txcaldav/calendarstore/test/test_file.py 2010-05-05 00:00:59 UTC (rev 5564)
+++ CalendarServer/branches/users/wsanchez/transations/txcaldav/calendarstore/test/test_file.py 2010-05-05 00:02:56 UTC (rev 5565)
@@ -25,7 +25,10 @@
from twext.python.vcomponent import VComponent
+from twext.web2.dav import davxml
+
from txdav.idav import IPropertyStore
+from txdav.propertystore.base import PropertyName
from txcaldav.icalendarstore import ICalendarStore, ICalendarHome
from txcaldav.icalendarstore import ICalendar, ICalendarObject
@@ -353,6 +356,20 @@
assert self.home1.calendarWithName(name) is None
self.home1.createCalendarWithName(name)
self.failUnless(self.home1.calendarWithName(name) is not None)
+ def checkProperties():
+ calendarProperties = self.home1.calendarWithName(name).properties()
+ self.assertEquals(
+ calendarProperties[
+ PropertyName.fromString(davxml.ResourceType.sname())
+ ],
+ davxml.ResourceType.calendar)
+ checkProperties()
+ self.txn.commit()
+ self.home1 = self.calendarStore.newTransaction().calendarHomeWithUID(
+ "home1")
+ # Sanity check: are the properties actually persisted?
+ # FIXME: no independent testing of this right now
+ checkProperties()
def test_createCalendarWithName_exists(self):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100504/b5400e6e/attachment-0001.html>
More information about the calendarserver-changes
mailing list