[CalendarServer-changes] [2640] CalendarServer/branches/sqlpropstore-2629/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jun 30 07:46:12 PDT 2008
Revision: 2640
http://trac.macosforge.org/projects/calendarserver/changeset/2640
Author: cdaboo at apple.com
Date: 2008-06-30 07:46:11 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
Add option to force properties of a collection to be stored inside the collection.
Modified Paths:
--------------
CalendarServer/branches/sqlpropstore-2629/twistedcaldav/sqlprops.py
CalendarServer/branches/sqlpropstore-2629/twistedcaldav/test/test_sqlprops.py
Modified: CalendarServer/branches/sqlpropstore-2629/twistedcaldav/sqlprops.py
===================================================================
--- CalendarServer/branches/sqlpropstore-2629/twistedcaldav/sqlprops.py 2008-06-28 17:59:54 UTC (rev 2639)
+++ CalendarServer/branches/sqlpropstore-2629/twistedcaldav/sqlprops.py 2008-06-30 14:46:11 UTC (rev 2640)
@@ -44,7 +44,7 @@
A dead property store that uses an SQLite database back end.
"""
- def __init__(self, resource, use_cache=True):
+ def __init__(self, resource, use_cache=True, use_parent_db=True):
self.resource = resource
if os.path.exists(os.path.dirname(resource.fp.path)):
if resource.isCollection():
@@ -54,10 +54,13 @@
from twistedcaldav.root import RootResource
from twistedcaldav.directory.calendar import DirectoryCalendarHomeResource
- if resource.isCollection() and (
+ if (
isinstance(resource, RootResource) or
isinstance(resource, DirectoryCalendarHomeResource)
):
+ use_parent_db = False
+
+ if resource.isCollection() and not use_parent_db:
self.rname = ""
self.index = self.childindex
else:
Modified: CalendarServer/branches/sqlpropstore-2629/twistedcaldav/test/test_sqlprops.py
===================================================================
--- CalendarServer/branches/sqlpropstore-2629/twistedcaldav/test/test_sqlprops.py 2008-06-28 17:59:54 UTC (rev 2639)
+++ CalendarServer/branches/sqlpropstore-2629/twistedcaldav/test/test_sqlprops.py 2008-06-30 14:46:11 UTC (rev 2640)
@@ -374,4 +374,29 @@
collection_index = sqlPropertyStore(collection)
collection_index.cacheAllChildProperties()
-
\ No newline at end of file
+
+ def test_user_parent_db(self):
+
+ collection_name, _ignore = self.mkdtemp("sql")
+
+ collection_name1 = os.path.join(collection_name, "1")
+ os.mkdir(collection_name1)
+ collection_name1_A = os.path.join(collection_name1, "A")
+ os.mkdir(collection_name1_A)
+ collection1 = CalDAVFile(collection_name1_A)
+ collection1_index = sqlPropertyStore(collection1)
+ for prop in SQLProps.props:
+ self._setProperty(collection1_index, prop)
+ self.assertTrue(os.path.exists(os.path.join(collection_name1, SQLPropertiesDatabase.dbFilename)))
+ self.assertFalse(os.path.exists(os.path.join(collection_name1_A, SQLPropertiesDatabase.dbFilename)))
+
+ collection_name2 = os.path.join(collection_name, "2")
+ os.mkdir(collection_name2)
+ collection_name2_A = os.path.join(collection_name2, "A")
+ os.mkdir(collection_name2_A)
+ collection2 = CalDAVFile(collection_name2_A)
+ collection2_index = sqlPropertyStore(collection2, use_parent_db=False)
+ for prop in SQLProps.props:
+ self._setProperty(collection2_index, prop)
+ self.assertFalse(os.path.exists(os.path.join(collection_name2, SQLPropertiesDatabase.dbFilename)))
+ self.assertTrue(os.path.exists(os.path.join(collection_name2_A, SQLPropertiesDatabase.dbFilename)))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080630/a701f1a3/attachment.html
More information about the calendarserver-changes
mailing list