[CalendarServer-changes] [5557] CalendarServer/trunk/twistedcaldav/directory
source_changes at macosforge.org
source_changes at macosforge.org
Mon May 3 15:35:41 PDT 2010
Revision: 5557
http://trac.macosforge.org/projects/calendarserver/changeset/5557
Author: sagen at apple.com
Date: 2010-05-03 15:35:39 -0700 (Mon, 03 May 2010)
Log Message:
-----------
Generate a default augment record even if one isn't present in the db
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/directory/augment.py
CalendarServer/trunk/twistedcaldav/directory/test/test_augment.py
Modified: CalendarServer/trunk/twistedcaldav/directory/augment.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/augment.py 2010-05-03 03:44:37 UTC (rev 5556)
+++ CalendarServer/trunk/twistedcaldav/directory/augment.py 2010-05-03 22:35:39 UTC (rev 5557)
@@ -80,15 +80,23 @@
if result is None:
if not hasattr(self, "_defaultRecord"):
self._defaultRecord = (yield self._lookupAugmentRecord("Default"))
- if self._defaultRecord is not None:
- result = copy.deepcopy(self._defaultRecord)
- result.uid = uid
+ if self._defaultRecord is None:
+ # No default was specified in the db, so generate one
+ self._defaultRecord = AugmentRecord(
+ "Default",
+ enabled=True,
+ enabledForCalendaring=True,
+ enabledForAddressBooks=True,
+ )
- # Mark default-cloned augment records as such so
- # DirectoryRecord.addAugmentInformation( ) can avoid unneccesary
- # error messages:
- result.clonedFromDefault = True
+ result = copy.deepcopy(self._defaultRecord)
+ result.uid = uid
+ # Mark default-cloned augment records as such so
+ # DirectoryRecord.addAugmentInformation( ) can avoid unneccesary
+ # error messages:
+ result.clonedFromDefault = True
+
returnValue(result)
@inlineCallbacks
Modified: CalendarServer/trunk/twistedcaldav/directory/test/test_augment.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/test/test_augment.py 2010-05-03 03:44:37 UTC (rev 5556)
+++ CalendarServer/trunk/twistedcaldav/directory/test/test_augment.py 2010-05-03 22:35:39 UTC (rev 5557)
@@ -59,10 +59,10 @@
self.assertEqual(getattr(record, k), v)
@inlineCallbacks
- def _checkNoRecord(self, db, uid):
+ def _checkRecordExists(self, db, uid):
record = (yield db.getAugmentRecord(uid))
- self.assertTrue(record is None)
+ self.assertTrue(record is not None)
class AugmentXMLTests(AugmentTests):
@@ -74,7 +74,9 @@
for item in testRecords:
yield self._checkRecord(db, item)
- yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
+ # Verify that a default record is returned, even if not specified
+ # in the DB
+ yield self._checkRecordExists(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
@inlineCallbacks
def test_read_default(self):
@@ -162,7 +164,9 @@
for item in testRecords:
yield self._checkRecord(db, item)
- yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
+ # Verify that a default record is returned, even if not specified
+ # in the DB
+ yield self._checkRecordExists(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
@inlineCallbacks
def test_read_default(self):
@@ -189,7 +193,9 @@
for item in testRecords:
yield self._checkRecord(db, item)
- yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
+ # Verify that a default record is returned, even if not specified
+ # in the DB
+ yield self._checkRecordExists(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
newrecord = AugmentRecord(
**testAddRecords[0]
@@ -227,7 +233,9 @@
for item in testRecords:
yield self._checkRecord(db, item)
- yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
+ # Verify that a default record is returned, even if not specified
+ # in the DB
+ yield self._checkRecordExists(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
@inlineCallbacks
def test_read_default(self):
@@ -255,7 +263,9 @@
for item in testRecords:
yield self._checkRecord(db, item)
- yield self._checkNoRecord(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
+ # Verify that a default record is returned, even if not specified
+ # in the DB
+ yield self._checkRecordExists(db, "D11F03A0-97EA-48AF-9A6C-FAC7F3975767")
newrecord = AugmentRecord(
**testAddRecords[0]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100503/bbd2b27c/attachment.html>
More information about the calendarserver-changes
mailing list