[CalendarServer-changes] [6377] CalendarServer/branches/users/glyph/more-deferreds-7
source_changes at macosforge.org
source_changes at macosforge.org
Mon Sep 27 16:37:32 PDT 2010
Revision: 6377
http://trac.macosforge.org/projects/calendarserver/changeset/6377
Author: glyph at apple.com
Date: 2010-09-27 16:37:31 -0700 (Mon, 27 Sep 2010)
Log Message:
-----------
addressbookObjectWithName / UID
Modified Paths:
--------------
CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/method/report_addressbook_query.py
CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/notifications.py
CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/resource.py
CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/storebridge.py
CalendarServer/branches/users/glyph/more-deferreds-7/txdav/caldav/datastore/sql.py
CalendarServer/branches/users/glyph/more-deferreds-7/txdav/carddav/datastore/test/common.py
CalendarServer/branches/users/glyph/more-deferreds-7/txdav/carddav/datastore/test/test_file.py
CalendarServer/branches/users/glyph/more-deferreds-7/txdav/carddav/iaddressbookstore.py
CalendarServer/branches/users/glyph/more-deferreds-7/txdav/common/datastore/sql_legacy.py
Modified: CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/method/report_addressbook_query.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/method/report_addressbook_query.py 2010-09-27 20:27:32 UTC (rev 6376)
+++ CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/method/report_addressbook_query.py 2010-09-27 23:37:31 UTC (rev 6377)
@@ -1,3 +1,4 @@
+# -*- test-case-name: twistedcaldav.test.test_addressbookquery -*-
##
# Copyright (c) 2006-2010 Apple Inc. All rights reserved.
#
@@ -146,12 +147,12 @@
for vCardRecord in records:
# match against original filter
- if filter.match(vCardRecord.vCard()):
+ if filter.match((yield vCardRecord.vCard())):
# Check size of results is within limit
checkMaxResults()
- yield report_common.responseForHref(request, responses, vCardRecord.hRef(), vCardRecord, propertiesForResource, query, vcard=vCardRecord.vCard())
+ yield report_common.responseForHref(request, responses, vCardRecord.hRef(), vCardRecord, propertiesForResource, query, vcard=(yield vCardRecord.vCard()))
@@ -228,13 +229,12 @@
(davxml.Read(),),
inherited_aces=filteredaces
)
-
for child, child_uri in ok_resources:
child_uri_name = child_uri[child_uri.rfind("/") + 1:]
child_path_name = urllib.unquote(child_uri_name)
if generate_address_data or not index_query_ok:
- vcard = addrresource.vCard(child_path_name)
+ vcard = yield addrresource.vCard(child_path_name)
assert vcard is not None, "vCard %s is missing from address book collection %r" % (child_uri_name, self)
else:
vcard = None
@@ -262,7 +262,7 @@
handled = True
if not handled:
- vcard = addrresource.vCard()
+ vcard = yield addrresource.vCard()
yield queryAddressBookObjectResource(addrresource, uri, None, vcard)
if limited[0]:
Modified: CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/notifications.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/notifications.py 2010-09-27 20:27:32 UTC (rev 6376)
+++ CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/notifications.py 2010-09-27 23:37:31 UTC (rev 6377)
@@ -27,7 +27,8 @@
from twext.web2 import responsecode
from twext.web2.dav import davxml
-from twisted.internet.defer import succeed, inlineCallbacks, returnValue
+from twisted.internet.defer import succeed, inlineCallbacks, returnValue,\
+ maybeDeferred
from twistedcaldav.resource import ReadOnlyNoCopyResourceMixIn, CalDAVResource
from twistedcaldav.sql import AbstractSQLDatabase, db_prefix
@@ -93,13 +94,13 @@
return succeed([])
def getNotifictionMessageByUID(self, request, uid):
- return succeed(self.notificationsDB().recordForUID(uid))
+ return maybeDeferred(self.notificationsDB().recordForUID, uid)
@inlineCallbacks
def deleteNotifictionMessageByUID(self, request, uid):
# See if it exists and delete the resource
- record = self.notificationsDB().recordForUID(uid)
+ record = yield self.notificationsDB().recordForUID(uid)
if record:
yield self.deleteNotification(request, record)
@@ -107,7 +108,7 @@
def deleteNotifictionMessageByName(self, request, rname):
# See if it exists and delete the resource
- record = self.notificationsDB().recordForName(rname)
+ record = yield self.notificationsDB().recordForName(rname)
if record:
yield self.deleteNotification(request, record)
Modified: CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/resource.py 2010-09-27 20:27:32 UTC (rev 6376)
+++ CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/resource.py 2010-09-27 23:37:31 UTC (rev 6377)
@@ -1164,6 +1164,8 @@
return principal
return None
+
+ @inlineCallbacks
def vCard(self, name=None):
"""
See L{ICalDAVResource.vCard}.
@@ -1176,17 +1178,19 @@
methods.
"""
try:
- vcard_data = self.vCardText(name)
+ vcard_data = yield self.vCardText(name)
except InternalDataStoreError:
- return None
+ returnValue(None)
- if vcard_data is None: return None
+ if vcard_data is None:
+ returnValue(None)
try:
- return vComponent.fromString(vcard_data)
+ returnValue(vComponent.fromString(vcard_data))
except ValueError:
- return None
+ returnValue(None)
+
def supportedReports(self):
result = super(CalDAVResource, self).supportedReports()
result.append(davxml.Report(caldavxml.CalendarQuery(),))
@@ -1537,24 +1541,23 @@
# TODO: just catenate all the vCards together
yield fail(HTTPError((ErrorResponse(responsecode.BAD_REQUEST))))
+
+ @inlineCallbacks
def vCardText(self, name=None):
if self.isAddressBookCollection():
if name is None:
- return str(self.vCard())
-
- vcard_resource = self.getChild(name)
- return vcard_resource.vCardText()
-
+ returnValue(str((yield self.vCard())))
+ vcard_resource = yield self.getChild(name)
+ returnValue((yield vcard_resource.vCardText()))
elif self.isCollection():
- return None
-
+ returnValue(None)
else:
if name is not None:
raise AssertionError("name must be None for non-collection vcard resource")
-
# FIXME: StoreBridge handles this case
raise NotImplementedError
+
def vCardXML(self, name=None):
return carddavxml.AddressData.fromAddressData(self.vCardText(name))
Modified: CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/storebridge.py 2010-09-27 20:27:32 UTC (rev 6376)
+++ CalendarServer/branches/users/glyph/more-deferreds-7/twistedcaldav/storebridge.py 2010-09-27 23:37:31 UTC (rev 6377)
@@ -1337,12 +1337,13 @@
self._initializeWithAddressBook(addressbook, home)
+ @inlineCallbacks
def makeChild(self, name):
"""
Create a L{AddressBookObjectResource} or L{ProtoAddressBookObjectResource} based on a
path object.
"""
- newStoreObject = self._newStoreAddressBook.addressbookObjectWithName(name)
+ newStoreObject = yield self._newStoreAddressBook.addressbookObjectWithName(name)
if newStoreObject is not None:
similar = AddressBookObjectResource(
@@ -1362,7 +1363,7 @@
# FIXME: tests should be failing without this line.
# Specifically, http_PUT won't be committing its transaction properly.
self.propagateTransaction(similar)
- return similar
+ returnValue(similar)
@inlineCallbacks
@@ -1775,7 +1776,12 @@
self._newStoreParentAddressBook.createAddressBookObjectWithName(
self.name(), component
)
- AddressBookObjectResource.transform(self, self._newStoreParentAddressBook.addressbookObjectWithName(self.name()))
+ AddressBookObjectResource.transform(
+ self,
+ (yield self._newStoreParentAddressBook.addressbookObjectWithName(
+ self.name())
+ )
+ )
returnValue(CREATED)
Modified: CalendarServer/branches/users/glyph/more-deferreds-7/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-7/txdav/caldav/datastore/sql.py 2010-09-27 20:27:32 UTC (rev 6376)
+++ CalendarServer/branches/users/glyph/more-deferreds-7/txdav/caldav/datastore/sql.py 2010-09-27 23:37:31 UTC (rev 6377)
@@ -46,7 +46,7 @@
CommonObjectResource
from txdav.common.datastore.sql_legacy import \
PostgresLegacyIndexEmulator, SQLLegacyCalendarInvites,\
- SQLLegacyCalendarShares
+ SQLLegacyCalendarShares, PostgresLegacyInboxIndexEmulator
from txdav.common.datastore.sql_tables import CALENDAR_TABLE,\
CALENDAR_BIND_TABLE, CALENDAR_OBJECT_REVISIONS_TABLE, CALENDAR_OBJECT_TABLE,\
_ATTACHMENTS_MODE_WRITE
@@ -105,22 +105,20 @@
def __init__(self, home, name, resourceID, notifier):
"""
- Initialize a calendar pointing at a path on disk.
+ Initialize a calendar pointing at a record in a database.
- @param name: the subdirectory of calendarHome where this calendar
- resides.
+ @param name: the name of the calendar resource.
@type name: C{str}
- @param calendarHome: the home containing this calendar.
- @type calendarHome: L{CalendarHome}
-
- @param realName: If this calendar was just created, the name which it
- will eventually have on disk.
- @type realName: C{str}
+ @param home: the home containing this calendar.
+ @type home: L{CalendarHome}
"""
super(Calendar, self).__init__(home, name, resourceID, notifier)
- self._index = PostgresLegacyIndexEmulator(self)
+ if name == 'inbox':
+ self._index = PostgresLegacyInboxIndexEmulator(self)
+ else:
+ self._index = PostgresLegacyIndexEmulator(self)
self._invites = SQLLegacyCalendarInvites(self)
self._objectResourceClass = CalendarObject
self._bindTable = CALENDAR_BIND_TABLE
Modified: CalendarServer/branches/users/glyph/more-deferreds-7/txdav/carddav/datastore/test/common.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-7/txdav/carddav/datastore/test/common.py 2010-09-27 20:27:32 UTC (rev 6376)
+++ CalendarServer/branches/users/glyph/more-deferreds-7/txdav/carddav/datastore/test/common.py 2010-09-27 23:37:31 UTC (rev 6377)
@@ -155,8 +155,8 @@
Get the addressbook detailed by
C{requirements['home1']['addressbook_1']['1.vcf']}.
"""
- returnValue((yield self.addressbookUnderTest())
- .addressbookObjectWithName("1.vcf"))
+ returnValue((yield (yield self.addressbookUnderTest())
+ .addressbookObjectWithName("1.vcf")))
def test_addressbookStoreProvides(self):
@@ -389,7 +389,7 @@
for addressbookObject in addressbookObjects:
self.assertProvides(IAddressBookObject, addressbookObject)
self.assertEquals(
- addressbook1.addressbookObjectWithName(addressbookObject.name()),
+ (yield addressbook1.addressbookObjectWithName(addressbookObject.name())),
addressbookObject
)
@@ -432,7 +432,7 @@
"""
addressbook1 = yield self.addressbookUnderTest()
for name in addressbook1_objectNames:
- addressbookObject = addressbook1.addressbookObjectWithName(name)
+ addressbookObject = yield addressbook1.addressbookObjectWithName(name)
self.assertProvides(IAddressBookObject, addressbookObject)
self.assertEquals(addressbookObject.name(), name)
# FIXME: add more tests based on CommonTests.requirements
@@ -445,7 +445,7 @@
don't exist.
"""
addressbook1 = yield self.addressbookUnderTest()
- self.assertEquals(addressbook1.addressbookObjectWithName("xyzzy"), None)
+ self.assertEquals((yield addressbook1.addressbookObjectWithName("xyzzy")), None)
@inlineCallbacks
@@ -456,15 +456,17 @@
addressbook = yield self.addressbookUnderTest()
for name in addressbook1_objectNames:
uid = (u'uid' + name.rstrip(".vcf"))
- self.assertNotIdentical(addressbook.addressbookObjectWithUID(uid),
- None)
+ self.assertNotIdentical(
+ (yield addressbook.addressbookObjectWithUID(uid)),
+ None
+ )
addressbook.removeAddressBookObjectWithUID(uid)
self.assertEquals(
- addressbook.addressbookObjectWithUID(uid),
+ (yield addressbook.addressbookObjectWithUID(uid)),
None
)
self.assertEquals(
- addressbook.addressbookObjectWithName(name),
+ (yield addressbook.addressbookObjectWithName(name)),
None
)
@@ -477,11 +479,11 @@
addressbook = yield self.addressbookUnderTest()
for name in addressbook1_objectNames:
self.assertNotIdentical(
- addressbook.addressbookObjectWithName(name), None
+ (yield addressbook.addressbookObjectWithName(name)), None
)
addressbook.removeAddressBookObjectWithName(name)
self.assertIdentical(
- addressbook.addressbookObjectWithName(name), None
+ (yield addressbook.addressbookObjectWithName(name)), None
)
# Make sure notifications are fired after commit
@@ -575,7 +577,10 @@
don't exist.
"""
addressbook1 = yield self.addressbookUnderTest()
- self.assertEquals(addressbook1.addressbookObjectWithUID("xyzzy"), None)
+ self.assertEquals(
+ (yield addressbook1.addressbookObjectWithUID("xyzzy")),
+ None
+ )
@inlineCallbacks
@@ -626,11 +631,11 @@
"""
addressbook1 = yield self.addressbookUnderTest()
name = "4.vcf"
- self.assertIdentical(addressbook1.addressbookObjectWithName(name), None)
+ self.assertIdentical((yield addressbook1.addressbookObjectWithName(name)), None)
component = VComponent.fromString(vcard4_text)
addressbook1.createAddressBookObjectWithName(name, component)
- addressbookObject = addressbook1.addressbookObjectWithName(name)
+ addressbookObject = yield addressbook1.addressbookObjectWithName(name)
self.assertEquals(addressbookObject.component(), component)
yield self.commit()
@@ -695,7 +700,7 @@
"""
addressbook1 = yield self.addressbookUnderTest()
component = VComponent.fromString(vcard4_text)
- addressbookObject = addressbook1.addressbookObjectWithName("1.vcf")
+ addressbookObject = yield addressbook1.addressbookObjectWithName("1.vcf")
self.assertRaises(
InvalidObjectResourceError,
addressbookObject.setComponent, component
@@ -736,14 +741,14 @@
component = VComponent.fromString(vcard1modified_text)
addressbook1 = yield self.addressbookUnderTest()
- addressbookObject = addressbook1.addressbookObjectWithName("1.vcf")
+ addressbookObject = yield addressbook1.addressbookObjectWithName("1.vcf")
oldComponent = addressbookObject.component()
self.assertNotEqual(component, oldComponent)
addressbookObject.setComponent(component)
self.assertEquals(addressbookObject.component(), component)
# Also check a new instance
- addressbookObject = addressbook1.addressbookObjectWithName("1.vcf")
+ addressbookObject = yield addressbook1.addressbookObjectWithName("1.vcf")
self.assertEquals(addressbookObject.component(), component)
yield self.commit()
@@ -799,7 +804,7 @@
addressbook.createAddressBookObjectWithName(
"4.vcf", VComponent.fromString(vcard4_text)
)
- newEvent = addressbook.addressbookObjectWithName("4.vcf")
+ newEvent = yield addressbook.addressbookObjectWithName("4.vcf")
self.assertEquals(newEvent.properties().items(), [])
@@ -873,11 +878,11 @@
objects = list((yield (yield home2.addressbookWithName("addressbook")).addressbookObjects()))
self.assertEquals(objects, [])
for resourceName in self.requirements['home1']['addressbook_1'].keys():
- obj = addressbook1.addressbookObjectWithName(resourceName)
+ obj = yield addressbook1.addressbookObjectWithName(resourceName)
self.assertIdentical(
- addressbook2.addressbookObjectWithName(resourceName), None)
+ (yield addressbook2.addressbookObjectWithName(resourceName)), None)
self.assertIdentical(
- addressbook2.addressbookObjectWithUID(obj.uid()), None)
+ (yield addressbook2.addressbookObjectWithUID(obj.uid())), None)
@inlineCallbacks
Modified: CalendarServer/branches/users/glyph/more-deferreds-7/txdav/carddav/datastore/test/test_file.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-7/txdav/carddav/datastore/test/test_file.py 2010-09-27 20:27:32 UTC (rev 6376)
+++ CalendarServer/branches/users/glyph/more-deferreds-7/txdav/carddav/datastore/test/test_file.py 2010-09-27 23:37:31 UTC (rev 6377)
@@ -208,6 +208,7 @@
set((yield addressbook.addressbookObjects())))
+ @inlineCallbacks
def test_addressbookObjectWithName_dot(self):
"""
Filenames starting with "." are reserved by this
@@ -216,7 +217,10 @@
"""
name = ".foo.vcf"
self.home1._path.child(name).touch()
- self.assertEquals(self.addressbook1.addressbookObjectWithName(name), None)
+ self.assertEquals(
+ (yield self.addressbook1.addressbookObjectWithName(name)),
+ None
+ )
@featureUnimplemented
@@ -224,14 +228,15 @@
"""
Find existing addressbook object by name.
"""
- addressbookObject = self.addressbook1.addressbookObjectWithUID("1")
+ addressbookObject = yield self.addressbook1.addressbookObjectWithUID("1")
self.failUnless(
isinstance(addressbookObject, AddressBookObject),
addressbookObject
)
self.assertEquals(
addressbookObject.component(),
- self.addressbook1.addressbookObjectWithName("1.vcf").component()
+ (yield self.addressbook1.addressbookObjectWithName("1.vcf")
+ ).component()
)
@@ -255,7 +260,10 @@
should raise.
"""
name = "foo.vcf"
- assert self.addressbook1.addressbookObjectWithName(name) is None
+ self.assertIdentical(
+ (yield self.addressbook1.addressbookObjectWithName(name)),
+ None
+ )
component = VComponent.fromString(vcard1modified_text)
self.assertRaises(
ObjectResourceUIDAlreadyExistsError,
@@ -350,12 +358,12 @@
)
# Sanity check.
self.assertEquals(
- self.addressbook1.addressbookObjectWithName("1.vcf").component(),
+ (yield self.addressbook1.addressbookObjectWithName("1.vcf")).component(),
VComponent.fromString(vcard1modified_text)
)
yield self.doThenUndo()
self.assertEquals(
- self.addressbook1.addressbookObjectWithName("1.vcf").component(),
+ (yield self.addressbook1.addressbookObjectWithName("1.vcf")).component(),
originalComponent
)
@@ -366,12 +374,12 @@
memory, to avoid unnecessary parsing round-trips.
"""
modifiedComponent = VComponent.fromString(vcard1modified_text)
- self.addressbook1.addressbookObjectWithName("1.vcf").setComponent(
+ (yield self.addressbook1.addressbookObjectWithName("1.vcf")).setComponent(
modifiedComponent
)
self.assertIdentical(
modifiedComponent,
- self.addressbook1.addressbookObjectWithName("1.vcf").component()
+ (yield self.addressbook1.addressbookObjectWithName("1.vcf")).component()
)
self.txn.commit()
@@ -414,9 +422,11 @@
class AddressBookObjectTest(unittest.TestCase):
+
+ @inlineCallbacks
def setUp(self):
- setUpAddressBook1(self)
- self.object1 = self.addressbook1.addressbookObjectWithName("1.vcf")
+ yield setUpAddressBook1(self)
+ self.object1 = yield self.addressbook1.addressbookObjectWithName("1.vcf")
def test_init(self):
Modified: CalendarServer/branches/users/glyph/more-deferreds-7/txdav/carddav/iaddressbookstore.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-7/txdav/carddav/iaddressbookstore.py 2010-09-27 20:27:32 UTC (rev 6376)
+++ CalendarServer/branches/users/glyph/more-deferreds-7/txdav/carddav/iaddressbookstore.py 2010-09-27 23:37:31 UTC (rev 6377)
@@ -147,8 +147,9 @@
in this addressbook.
@param name: a string.
- @return: an L{IAddressBookObject} or C{None} if no such addressbook
- object exists.
+
+ @return: a L{Deferred} that fires with an L{IAddressBookObject} or
+ C{None} if no such addressbook object exists.
"""
def addressbookObjectWithUID(uid):
Modified: CalendarServer/branches/users/glyph/more-deferreds-7/txdav/common/datastore/sql_legacy.py
===================================================================
--- CalendarServer/branches/users/glyph/more-deferreds-7/txdav/common/datastore/sql_legacy.py 2010-09-27 20:27:32 UTC (rev 6376)
+++ CalendarServer/branches/users/glyph/more-deferreds-7/txdav/common/datastore/sql_legacy.py 2010-09-27 23:37:31 UTC (rev 6377)
@@ -808,7 +808,38 @@
return "%%%s%%" % (arg,)
-class PostgresLegacyIndexEmulator(LoggingMixIn):
+class LegacyIndexHelper(LoggingMixIn, object):
+
+ @inlineCallbacks
+ def isAllowedUID(self, uid, *names):
+ """
+ Checks to see whether to allow an operation which would add the
+ specified UID to the index. Specifically, the operation may not
+ violate the constraint that UIDs must be unique.
+ @param uid: the UID to check
+ @param names: the names of resources being replaced or deleted by the
+ operation; UIDs associated with these resources are not checked.
+ @return: True if the UID is not in the index and is not reserved,
+ False otherwise.
+ """
+ rname = yield self.resourceNameForUID(uid)
+ returnValue(rname is None or rname in names)
+
+
+ def reserveUID(self, uid):
+ return self.reserver.reserveUID(uid)
+
+
+ def unreserveUID(self, uid):
+ return self.reserver.unreserveUID(uid)
+
+
+ def isReservedUID(self, uid):
+ return self.reserver.isReservedUID(uid)
+
+
+
+class PostgresLegacyIndexEmulator(LegacyIndexHelper):
"""
Emulator for L{twistedcaldv.index.Index} and
L{twistedcaldv.index.IndexSchedule}.
@@ -830,27 +861,6 @@
return self.calendar._txn
- def reserveUID(self, uid):
- if self.calendar._name == "inbox":
- return succeed(None)
- else:
- return self.reserver.reserveUID(uid)
-
-
- def unreserveUID(self, uid):
- if self.calendar._name == "inbox":
- return succeed(None)
- else:
- return self.reserver.unreserveUID(uid)
-
-
- def isReservedUID(self, uid):
- if self.calendar._name == "inbox":
- return succeed(False)
- else:
- return self.reserver.isReservedUID(uid)
-
-
@inlineCallbacks
def isAllowedUID(self, uid, *names):
"""
@@ -863,11 +873,8 @@
@return: True if the UID is not in the index and is not reserved,
False otherwise.
"""
- if self.calendar._name == "inbox":
- returnValue(True)
- else:
- rname = yield self.resourceNameForUID(uid)
- returnValue(rname is None or rname in names)
+ rname = yield self.resourceNameForUID(uid)
+ returnValue(rname is None or rname in names)
@inlineCallbacks
@@ -906,6 +913,7 @@
obj = self.calendar.calendarObjectWithName(name)
obj.updateDatabase(obj.component(), expand_until=expand_until, reCreate=True)
+
def testAndUpdateIndex(self, minDate):
# Find out if the index is expanded far enough
names = self.notExpandedBeyond(minDate)
@@ -915,6 +923,7 @@
self.log_info("Search falls outside range of index for %s %s" % (name, minDate))
self.reExpandResource(name, minDate)
+
def whatchanged(self, revision):
results = [
@@ -940,6 +949,7 @@
return changed, deleted,
+
def indexedSearch(self, filter, useruid='', fbtype=False):
"""
Finds resources matching the given qualifiers.
@@ -1031,7 +1041,26 @@
+class PostgresLegacyInboxIndexEmulator(PostgresLegacyIndexEmulator):
+ """
+ UIDs need not be unique in the 'inbox' calendar, so override those
+ behaviors intended to ensure that.
+ """
+ def isAllowedUID(self):
+ return succeed(True)
+
+ def reserveUID(self, uid):
+ return succeed(None)
+
+ def unreserveUID(self, uid):
+ return succeed(None)
+
+ def isReservedUID(self, uid):
+ return succeed(False)
+
+
+
# CARDDAV
class postgresqladbkgenerator(sqlgenerator):
@@ -1098,7 +1127,7 @@
return "%%%s%%" % (arg,)
-class PostgresLegacyABIndexEmulator(object):
+class PostgresLegacyABIndexEmulator(LegacyIndexHelper):
"""
Emulator for L{twistedcaldv.index.Index} and
L{twistedcaldv.index.IndexSchedule}.
@@ -1121,33 +1150,6 @@
return self.addressbook._txn
- def reserveUID(self, uid):
- return self.reserver.reserveUID(uid)
-
-
- def unreserveUID(self, uid):
- return self.reserver.unreserveUID(uid)
-
-
- def isReservedUID(self, uid):
- return self.reserver.isReservedUID(uid)
-
-
- def isAllowedUID(self, uid, *names):
- """
- Checks to see whether to allow an operation which would add the
- specified UID to the index. Specifically, the operation may not
- violate the constraint that UIDs must be unique.
- @param uid: the UID to check
- @param names: the names of resources being replaced or deleted by the
- operation; UIDs associated with these resources are not checked.
- @return: True if the UID is not in the index and is not reserved,
- False otherwise.
- """
- rname = self.resourceNameForUID(uid)
- return (rname is None or rname in names)
-
-
@inlineCallbacks
def resourceUIDForName(self, name):
obj = yield self.addressbook.addressbookObjectWithName(name)
@@ -1156,11 +1158,12 @@
returnValue(obj.uid())
+ @inlineCallbacks
def resourceNameForUID(self, uid):
- obj = self.addressbook.addressbookObjectWithUID(uid)
+ obj = yield self.addressbook.addressbookObjectWithUID(uid)
if obj is None:
- return None
- return obj.name()
+ returnValue(None)
+ returnValue(obj.name())
def whatchanged(self, revision):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100927/946bb7d0/attachment-0001.html>
More information about the calendarserver-changes
mailing list