[CalendarServer-changes] [11221] CalendarServer/trunk/txdav
source_changes at macosforge.org
source_changes at macosforge.org
Mon May 20 12:13:24 PDT 2013
Revision: 11221
http://trac.calendarserver.org//changeset/11221
Author: cdaboo at apple.com
Date: 2013-05-20 12:13:24 -0700 (Mon, 20 May 2013)
Log Message:
-----------
Remove use of resourceType which should not have been merged back. Fix issue when doing depth:1 property store load
for shared address books that have no actually properties set.
Modified Paths:
--------------
CalendarServer/trunk/txdav/base/propertystore/sql.py
CalendarServer/trunk/txdav/carddav/datastore/sql.py
Modified: CalendarServer/trunk/txdav/base/propertystore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/base/propertystore/sql.py 2013-05-18 02:34:26 UTC (rev 11220)
+++ CalendarServer/trunk/txdav/base/propertystore/sql.py 2013-05-20 19:13:24 UTC (rev 11221)
@@ -166,6 +166,17 @@
)
rows = yield query.on(txn, resourceIDs=resourceIDs)
stores = cls._createMultipleStores(defaultUser, txn, rows)
+
+ # Make sure we have a store for each resourceID even if no properties exist
+ for resourceID in resourceIDs:
+ if resourceID not in stores:
+ store = cls.__new__(cls)
+ super(PropertyStore, store).__init__(defaultUser)
+ store._txn = txn
+ store._resourceID = resourceID
+ store._cached = {}
+ stores[resourceID] = store
+
returnValue(stores)
Modified: CalendarServer/trunk/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/carddav/datastore/sql.py 2013-05-18 02:34:26 UTC (rev 11220)
+++ CalendarServer/trunk/txdav/carddav/datastore/sql.py 2013-05-20 19:13:24 UTC (rev 11221)
@@ -60,8 +60,6 @@
InvalidObjectResourceError, InvalidComponentForStoreError, \
AllRetriesFailed
-from txdav.xml.rfc2518 import ResourceType
-
from zope.interface.declarations import implements
@@ -93,7 +91,6 @@
def __repr__(self):
return '<%s: %s("%s")>' % (self.__class__.__name__, self._resourceID, self.name())
-
addressbooks = CommonHome.children
listAddressbooks = CommonHome.listChildren
loadAddressbooks = CommonHome.loadChildren
@@ -103,7 +100,7 @@
@classproperty
- def _resourceIDAndHomeResourceIDFromOwnerQuery(cls): #@NoSelf
+ def _resourceIDAndHomeResourceIDFromOwnerQuery(cls): #@NoSelf
home = cls._homeSchema
return Select([home.RESOURCE_ID, home.ADDRESSBOOK_PROPERTY_STORE_ID],
From=home, Where=home.OWNER_UID == Parameter("ownerUID"))
@@ -267,7 +264,7 @@
@classproperty
- def _syncTokenQuery(cls): #@NoSelf
+ def _syncTokenQuery(cls): #@NoSelf
"""
DAL Select statement to find the sync token.
"""
@@ -311,7 +308,7 @@
@classproperty
- def _changesQuery(cls): #@NoSelf
+ def _changesQuery(cls): #@NoSelf
rev = cls._revisionsSchema
return Select(
[rev.COLLECTION_NAME,
@@ -323,6 +320,7 @@
rev.RESOURCE_ID == rev.HOME_RESOURCE_ID)
)
+
@inlineCallbacks
def doChangesQuery(self, revision):
@@ -364,6 +362,7 @@
def __repr__(self):
return '<%s: %s("%s")>' % (self.__class__.__name__, self._resourceID, self.name())
+
@inlineCallbacks
def _init_isShared(self):
"""
@@ -379,6 +378,7 @@
else:
yield None
+
def getCreated(self):
return self.ownerHome()._created
@@ -394,7 +394,6 @@
def setModified(self, newValue):
self.ownerHome()._modified = newValue
-
_created = property(getCreated, setCreated,)
_modified = property(getModified, setModified,)
@@ -403,11 +402,6 @@
def _addressbookHome(self):
return self._home
-
- def resourceType(self):
- return ResourceType.addressbook #@UndefinedVariable
-
-
ownerAddressBookHome = CommonHomeChild.ownerHome
viewerAddressBookHome = CommonHomeChild.viewerHome
addressbookObjects = CommonHomeChild.objectResources
@@ -468,25 +462,21 @@
def remove(self):
if self._resourceID == self._home._resourceID:
- # allow remove, as a way to reset the address book to an empty state
+ # Allow remove, as a way to reset the address book to an empty state
for abo in (yield self.objectResources()):
yield abo.remove()
yield self.removedObjectResource(abo)
yield self.unshare() # storebridge should already have done this
- # don't delete. Note that revision table is NOT queried for removes
- # yield self._deletedSyncToken()
+ # Note that revision table is NOT queried for removes
yield self._updateRevision(self.name())
- # TODO: See why the following 2 lines do not work reliably
- # yield self.properties()._removeResource()
- # yield self._loadPropertyStore()
- for prop in self.properties():
- self.properties().pop(prop, None)
+ yield self.properties()._removeResource()
+ yield self._loadPropertyStore()
yield self.notifyChanged()
- yield self._home.bumpModified()
+ yield self._home.notifyChanged()
else:
returnValue((yield super(AddressBook, self).remove()))
@@ -560,7 +550,7 @@
Where=obj.ADDRESSBOOK_HOME_RESOURCE_ID == Parameter("addressbookResourceID"),)
- def _fullySharedAddressBookGroupRow(self): #@NoSelf
+ def _fullySharedAddressBookGroupRow(self): #@NoSelf
return [
self._resourceID, # obj.ADDRESSBOOK_HOME_RESOURCE_ID,
self._resourceID, # obj.RESOURCE_ID,
@@ -655,7 +645,7 @@
)
# get ownerHomeIDs
for dataRow in dataRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = dataRow[:cls.bindColumnCount] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = dataRow[:cls.bindColumnCount] #@UnusedVariable
ownerHome = yield home.ownerHomeWithChildID(resourceID)
ownerHomeToDataRowMap[ownerHome] = dataRow
@@ -664,7 +654,7 @@
home._txn, homeID=home._resourceID
)
for groupBindRow in groupBindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:cls.bindColumnCount] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:cls.bindColumnCount] #@UnusedVariable
ownerAddressBookID = yield AddressBookObject.ownerAddressBookFromGroupID(home._txn, resourceID)
ownerHome = yield home.ownerHomeWithChildID(ownerAddressBookID)
if ownerHome not in ownerHomeToDataRowMap:
@@ -687,7 +677,7 @@
# Create the actual objects merging in properties
for ownerHome, dataRow in ownerHomeToDataRowMap.iteritems():
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = dataRow[:cls.bindColumnCount] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = dataRow[:cls.bindColumnCount] #@UnusedVariable
additionalBind = dataRow[cls.bindColumnCount:cls.bindColumnCount + len(cls.additionalBindColumns())]
metadata = dataRow[cls.bindColumnCount + len(cls.additionalBindColumns()):]
@@ -781,7 +771,8 @@
if not rows:
returnValue(None)
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage, ownerAddressBookID, cachedBindStatus = rows[0][:cls.bindColumnCount + 2] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage, ownerAddressBookID, cachedBindStatus = rows[0] #@UnusedVariable
+
# if wrong status, exit here. Item is in queryCache
if (cachedBindStatus == _BIND_STATUS_ACCEPTED) != bool(accepted):
returnValue(None)
@@ -816,7 +807,7 @@
"""
bindRows = yield cls._bindForNameAndHomeID.on(home._txn, name=name, homeID=home._resourceID)
if bindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = bindRows[0] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = bindRows[0] #@UnusedVariable
if (bindStatus == _BIND_STATUS_ACCEPTED) != bool(accepted):
returnValue(None)
@@ -832,7 +823,7 @@
home._txn, name=name, homeID=home._resourceID
)
if groupBindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRows[0] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRows[0] #@UnusedVariable
if (bindStatus == _BIND_STATUS_ACCEPTED) != bool(accepted):
returnValue(None)
@@ -873,7 +864,7 @@
home._txn, resourceID=resourceID, homeID=home._resourceID
)
if bindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = bindRows[0] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = bindRows[0] #@UnusedVariable
if (bindStatus == _BIND_STATUS_ACCEPTED) != bool(accepted):
returnValue(None)
@@ -887,7 +878,7 @@
home._txn, homeID=home._resourceID, addressbookID=resourceID
)
if groupBindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRows[0] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRows[0] #@UnusedVariable
if (bindStatus == _BIND_STATUS_ACCEPTED) != bool(accepted):
returnValue(None)
@@ -958,7 +949,7 @@
home._txn, homeID=home._resourceID
)))
for row in rows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = row[:cls.bindColumnCount] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = row[:cls.bindColumnCount] #@UnusedVariable
ownerHome = yield home._txn.homeWithResourceID(home._homeType, resourceID)
names |= set([ownerHome.shareeAddressBookName()])
returnValue(tuple(names))
@@ -1028,7 +1019,7 @@
readWriteGroupIDs = []
readOnlyGroupIDs = []
for groupBindRow in groupBindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:self.bindColumnCount] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:self.bindColumnCount] #@UnusedVariable
if bindMode == _BIND_MODE_WRITE:
readWriteGroupIDs.append(resourceID)
else:
@@ -1044,6 +1035,7 @@
adjustedReadWriteGroupIDs = readWriteGroupIDs
returnValue((tuple(adjustedReadOnlyGroupIDs), tuple(adjustedReadWriteGroupIDs)))
+
#FIXME: Unused
@inlineCallbacks
def readOnlyGroupIDs(self):
@@ -1075,7 +1067,7 @@
readWriteGroupIDs = []
readOnlyGroupIDs = []
for groupBindRow in groupBindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:self.bindColumnCount] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:self.bindColumnCount] #@UnusedVariable
if bindMode == _BIND_MODE_WRITE:
readWriteGroupIDs.append(resourceID)
else:
@@ -1179,7 +1171,6 @@
shareeView._home._children.pop(shareeView._name, None)
shareeView._home._children.pop(shareeView._resourceID, None)
-
if message is not None:
shareeView._bindMessage = columnMap[bind.MESSAGE]
@@ -1215,7 +1206,7 @@
self._txn, resourceID=self._resourceID, homeID=self._home._resourceID
)
for bindRow in bindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = bindRow[:self.bindColumnCount] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = bindRow[:self.bindColumnCount] #@UnusedVariable
home = yield self._txn.homeWithResourceID(self._home._homeType, homeID)
new = yield home.childWithName(self.shareeAddressBookName())
result.append(new)
@@ -1242,7 +1233,7 @@
self._txn, resourceID=self._resourceID
)
for bindRow in bindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = bindRow[:self.bindColumnCount] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = bindRow[:self.bindColumnCount] #@UnusedVariable
home = yield self._txn.homeWithResourceID(self._home._homeType, homeID)
new = yield self.objectWithName(home, self.shareeAddressBookName(), accepted=False)
result.append(new)
@@ -1310,7 +1301,7 @@
#_homeChildMetaDataSchema = schema.ADDRESSBOOK_OBJECT
- def __init__(self, addressbook, name, uid, resourceID=None, options=None): #@UnusedVariable
+ def __init__(self, addressbook, name, uid, resourceID=None, options=None): #@UnusedVariable
self._kind = None
self._ownerAddressBookResourceID = None
@@ -1445,7 +1436,7 @@
@classproperty
- def _allColumnsWithResourceID(cls): #@NoSelf
+ def _allColumnsWithResourceID(cls): #@NoSelf
obj = cls._objectSchema
return Select(
cls._allColumns, From=obj,
@@ -1544,7 +1535,7 @@
if groupBindRows:
groupBindRow = groupBindRows[0]
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:self.bindColumnCount] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:self.bindColumnCount] #@UnusedVariable
self._bindMode = bindMode
self._bindStatus = bindStatus
self._bindMessage = bindMessage
@@ -1561,7 +1552,7 @@
@classproperty
- def _allColumns(cls): #@NoSelf
+ def _allColumns(cls): #@NoSelf
"""
Full set of columns in the object table that need to be loaded to
initialize the object resource state.
@@ -1675,7 +1666,7 @@
self.validAddressDataCheck(component, inserting)
- def validAddressDataCheck(self, component, inserting): #@UnusedVariable
+ def validAddressDataCheck(self, component, inserting): #@UnusedVariable
"""
Check that the calendar data is valid iCalendar.
@return: tuple: (True/False if the calendar data is valid,
@@ -1781,7 +1772,7 @@
@classproperty
- def _insertABObject(cls): #@NoSelf
+ def _insertABObject(cls): #@NoSelf
"""
DAL statement to create an addressbook object with all default values.
"""
@@ -1801,7 +1792,7 @@
@inlineCallbacks
- def updateDatabase(self, component, expand_until=None, reCreate=False, #@UnusedVariable
+ def updateDatabase(self, component, expand_until=None, reCreate=False, #@UnusedVariable
inserting=False):
"""
Update the database tables for the new data being written.
@@ -1816,7 +1807,7 @@
"resource": _ABO_KIND_RESOURCE,
"location": _ABO_KIND_LOCATION,
}
- lcResourceKind = component.resourceKind().lower() if component.resourceKind() else component.resourceKind();
+ lcResourceKind = component.resourceKind().lower() if component.resourceKind() else component.resourceKind()
kind = componentResourceKindToAddressBookObjectKindMap.get(lcResourceKind, _ABO_KIND_PERSON)
assert inserting or self._kind == kind # can't change kind. Should be checked in upper layers
self._kind = kind
@@ -2079,6 +2070,7 @@
"""
pass
+
# IDataStoreObject
def contentType(self):
"""
@@ -2105,6 +2097,7 @@
"""
return self._bindName
+
@inlineCallbacks
def setShared(self, shared):
"""
@@ -2133,6 +2126,7 @@
'''
yield None
+
@classmethod
def metadataColumns(cls):
"""
@@ -2149,7 +2143,7 @@
# same as CommonHomeChild._childrenAndMetadataForHomeID() w/o metadata join
@classproperty
- def _childrenAndMetadataForHomeID(cls): #@NoSelf
+ def _childrenAndMetadataForHomeID(cls): #@NoSelf
bind = cls._bindSchema
child = cls._objectSchema
columns = cls.bindColumns() + cls.additionalBindColumns() + cls.metadataColumns()
@@ -2161,7 +2155,6 @@
).And(bind.BIND_STATUS == _BIND_STATUS_ACCEPTED))
-
def notifyChanged(self):
return self._addressbook.notifyChanged()
@@ -2175,7 +2168,7 @@
@see: L{ICalendarHome.asShared}
@return: L{AddressBookObject} objects that represent this
- L{AddressBookObject} as a child of different L{AddressBooks}s
+ L{AddressBookObject} as a child of different L{AddressBooks}s
in different L{CommonHome}s
@rtype: a L{Deferred} which fires with a L{list} of L{AddressBookObject}s.
"""
@@ -2186,7 +2179,7 @@
self._txn, resourceID=self._resourceID, homeID=self._home._resourceID
)
for groupBindRow in groupBindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:self.bindColumnCount] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:self.bindColumnCount] #@UnusedVariable
home = yield self._txn.homeWithResourceID(self._home._homeType, homeID)
addressbook = yield home.childWithName(self._home.shareeAddressBookName())
new = yield addressbook.objectResourceWithID(resourceID)
@@ -2204,7 +2197,7 @@
@see: L{ICalendarHome.asShared}
@return: L{AddressBookObject} objects that represent this
- L{AddressBookObject} as a child of different L{AddressBooks}s
+ L{AddressBookObject} as a child of different L{AddressBooks}s
in different L{CommonHome}s
@rtype: a L{Deferred} which fires with a L{list} of L{AddressBookObject}s.
"""
@@ -2215,7 +2208,7 @@
self._txn, resourceID=self._resourceID
)
for groupBindRow in groupBindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:self.bindColumnCount] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:self.bindColumnCount] #@UnusedVariable
home = yield self._txn.homeWithResourceID(self._home._homeType, homeID)
addressbook = yield home.childWithName(self._home.shareeAddressBookName())
if not addressbook:
@@ -2227,7 +2220,7 @@
@classproperty
- def _addressbookIDForResourceID(cls): #@NoSelf
+ def _addressbookIDForResourceID(cls): #@NoSelf
obj = cls._objectSchema
return Select([obj.PARENT_RESOURCE_ID],
From=obj,
@@ -2352,7 +2345,7 @@
self._txn, resourceID=self._resourceID, homeID=shareeHome._resourceID
)
groupBindRow = groupBindRows[0]
- bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:self.bindColumnCount] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindRevision, bindMessage = groupBindRow[:self.bindColumnCount] #@UnusedVariable
if bindStatus == _BIND_STATUS_ACCEPTED:
group = yield shareeHome.objectWithShareUID(bindName)
else:
@@ -2367,12 +2360,12 @@
yield shareeView._initSyncToken()
yield shareeView._initBindRevision()
-
# Must send notification to ensure cache invalidation occurs
yield self.notifyChanged()
returnValue(bindName)
+
@inlineCallbacks
#TODO: This is almost the same as AddressBook.updateShare(): combine
def updateShare(self, shareeView, mode=None, status=None, message=None, name=None):
@@ -2405,7 +2398,6 @@
# TODO: raise a nice exception if shareeView is not, in fact, a shared
# version of this same L{CommonHomeChild}
-
#remove None parameters, and substitute None for empty string
bind = self._bindSchema
columnMap = dict([(k, v if v else None)
@@ -2466,7 +2458,7 @@
@classproperty
- def _acceptedBindForHomeIDAndAddressBookID(cls): #@NoSelf
+ def _acceptedBindForHomeIDAndAddressBookID(cls): #@NoSelf
bind = cls._bindSchema
abo = cls._objectSchema
return Select(
@@ -2480,7 +2472,7 @@
@classproperty
- def _unacceptedBindForHomeIDAndAddressBookID(cls): #@NoSelf
+ def _unacceptedBindForHomeIDAndAddressBookID(cls): #@NoSelf
bind = cls._bindSchema
abo = cls._objectSchema
return Select(
@@ -2494,7 +2486,7 @@
@classproperty
- def _bindForHomeIDAndAddressBookID(cls): #@NoSelf
+ def _bindForHomeIDAndAddressBookID(cls): #@NoSelf
bind = cls._bindSchema
abo = cls._objectSchema
return Select(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130520/de237cb0/attachment-0001.html>
More information about the calendarserver-changes
mailing list