[CalendarServer-changes] [10965] CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/ datastore/sql.py
source_changes at macosforge.org
source_changes at macosforge.org
Fri Mar 22 10:13:46 PDT 2013
Revision: 10965
http://trac.calendarserver.org//changeset/10965
Author: gaya at apple.com
Date: 2013-03-22 10:13:46 -0700 (Fri, 22 Mar 2013)
Log Message:
-----------
fix whitespace
Modified Paths:
--------------
CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py
Modified: CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py 2013-03-22 17:05:05 UTC (rev 10964)
+++ CalendarServer/branches/users/gaya/sharedgroups/txdav/carddav/datastore/sql.py 2013-03-22 17:13:46 UTC (rev 10965)
@@ -85,9 +85,11 @@
self._homeResourceID = None
self._addressbook = None
+
def __repr__(self):
return '<%s: %s("%s")>' % (self.__class__.__name__, self._resourceID, self.name())
+
addressbooks = CommonHome.children
listAddressbooks = CommonHome.listChildren
loadAddressbooks = CommonHome.loadChildren
@@ -97,7 +99,7 @@
@classproperty
- def _resourceIDAndHomeResourceIDFromOwnerQuery(cls): #@NoSelf
+ def _resourceIDAndHomeResourceIDFromOwnerQuery(cls): #@NoSelf
home = cls._homeSchema
return Select([home.RESOURCE_ID, home.HOME_RESOURCE_ID],
From=home, Where=home.OWNER_UID == Parameter("ownerUID"))
@@ -159,7 +161,7 @@
self.uid(),
self.uid(),
self._txn,
- self._homeResourceID, # not ._resourceID as in CommonHome._loadPropertyStore()
+ self._homeResourceID, # not ._resourceID as in CommonHome._loadPropertyStore()
notifyCallback=self.notifyChanged
)
self._propertyStore = props
@@ -261,7 +263,7 @@
@classproperty
- def _syncTokenQuery(cls): #@NoSelf
+ def _syncTokenQuery(cls): #@NoSelf
"""
DAL Select statement to find the sync token.
"""
@@ -305,7 +307,7 @@
@classproperty
- def _changesQuery(cls): #@NoSelf
+ def _changesQuery(cls): #@NoSelf
rev = cls._revisionsSchema
return Select(
[rev.RESOURCE_NAME, rev.DELETED],
@@ -362,9 +364,11 @@
self._index = PostgresLegacyABIndexEmulator(self)
self._bindName = bindName
+
def __repr__(self):
return '<%s: %s("%s")>' % (self.__class__.__name__, self._resourceID, self.name())
+
def getCreated(self):
return self.ownerHome()._created
@@ -391,7 +395,7 @@
def resourceType(self):
- return ResourceType.addressbook #@UndefinedVariable
+ return ResourceType.addressbook #@UndefinedVariable
#FIXME: Only used for shared group resouretype in SharedResourceMixin.upgradeToShare() and SharedResourceMixin.downgradeFromShare()
@@ -451,13 +455,13 @@
for abo in (yield self.objectResources()):
yield self.removeObjectResource(abo)
- yield self.unshare() # storebridge should already have done this
+ yield self.unshare() # storebridge should already have done this
# don't delete. Note that revision table is NOT queried for removes
- #yield self._deletedSyncToken()
+ # yield self._deletedSyncToken()
yield self._updateRevision(self.name())
- # TODO: See why the following 2 line do not work reliably
+ # TODO: See why the following 2 lines do not work reliably
# yield self.properties()._removeResource()
# yield self._loadPropertyStore()
for prop in self.properties():
@@ -474,7 +478,7 @@
def rename(self, name):
# better error?
- #raise HomeChildNameNotAllowedError
+ # raise HomeChildNameNotAllowedError
raise HTTPError(FORBIDDEN)
@@ -552,18 +556,18 @@
@inlineCallbacks
- def _groupForEntireAB_Row(self): #@NoSelf
+ def _groupForEntireAB_Row(self): #@NoSelf
returnValue([
- self._resourceID, # obj.ADDRESSBOOK_RESOURCE_ID,
- self._resourceID, # obj.RESOURCE_ID,
- (yield self._groupForEntireAB_Name()), # obj.RESOURCE_NAME, shared name is UID and thus avoids collisions
- (yield self._groupForEntireAB_UID()), # obj.UID, shared name is uuid
- _ABO_KIND_GROUP, # obj.KIND,
- "1", # obj.MD5, unused
- "1", # Len(obj.TEXT), unused
- self._created, # obj.CREATED,
- self._modified, # obj.CREATED,
+ self._resourceID, # obj.ADDRESSBOOK_RESOURCE_ID,
+ self._resourceID, # obj.RESOURCE_ID,
+ (yield self._groupForEntireAB_Name()), # obj.RESOURCE_NAME, shared name is UID and thus avoids collisions
+ (yield self._groupForEntireAB_UID()), # obj.UID, shared name is uuid
+ _ABO_KIND_GROUP, # obj.KIND,
+ "1", # obj.MD5, unused
+ "1", # Len(obj.TEXT), unused
+ self._created, # obj.CREATED,
+ self._modified, # obj.CREATED,
])
@@ -648,7 +652,7 @@
)
# get ownerHomeIDs
for dataRow in dataRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = dataRow[:6] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = dataRow[:6] #@UnusedVariable
assert bindStatus != _BIND_MODE_OWN
ownerHome = yield home.ownerHomeWithChildID(resourceID)
ownerHomeToDataRowMap[ownerHome] = dataRow
@@ -658,14 +662,14 @@
home._txn, homeID=home._resourceID
)
for groupBindRow in groupBindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = groupBindRow[:6] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = groupBindRow[:6] #@UnusedVariable
ownerAddressBookID = yield AddressBookObject.ownerAddressBookFromGroupID(home._txn, resourceID)
ownerHome = yield home.ownerHomeWithChildID(ownerAddressBookID)
if ownerHome not in ownerHomeToDataRowMap:
groupBindRow[0] = _BIND_MODE_WRITE
- groupBindRow[3] = None # bindName
- groupBindRow[4] = None # bindStatus
- groupBindRow[5] = None # bindMessage
+ groupBindRow[3] = None # bindName
+ groupBindRow[4] = None # bindStatus
+ groupBindRow[5] = None # bindMessage
ownerHomeToDataRowMap[ownerHome] = groupBindRow
if ownerHomeToDataRowMap:
@@ -679,7 +683,7 @@
# Create the actual objects merging in properties
for ownerHome, dataRow in ownerHomeToDataRowMap.iteritems():
- bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = dataRow[:6] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = dataRow[:6] #@UnusedVariable
metadata = dataRow[6:]
child = cls(
@@ -743,18 +747,18 @@
)
if rows:
rows[0].append(ownerAddressBook._resourceID)
- rows[0].append(rows[0][4]) # cachedStatus = bindStatus
+ rows[0].append(rows[0][4]) # cachedStatus = bindStatus
else:
groupBindRows = yield AddressBookObject._bindWithHomeIDAndAddressBookID.on(
home._txn, homeID=home._resourceID, addressbookID=ownerAddressBook._resourceID
)
if groupBindRows:
groupBindRow = groupBindRows[0]
- cachedBindStatus = groupBindRow[4] # save off bindStatus
+ cachedBindStatus = groupBindRow[4] # save off bindStatus
groupBindRow[0] = _BIND_MODE_WRITE
- groupBindRow[3] = None # bindName
- groupBindRow[4] = None # bindStatus
- groupBindRow[5] = None # bindMessage
+ groupBindRow[3] = None # bindName
+ groupBindRow[4] = None # bindStatus
+ groupBindRow[5] = None # bindMessage
groupBindRow.append(ownerAddressBook._resourceID)
groupBindRow.append(cachedBindStatus)
rows = [groupBindRow]
@@ -766,7 +770,7 @@
if not rows:
returnValue(None)
- bindMode, homeID, resourceID, bindName, bindStatus, bindMessage, ownerAddressBookID, cachedBindStatus = rows[0] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindMessage, ownerAddressBookID, cachedBindStatus = rows[0] #@UnusedVariable
# if wrong status, exit here. Item is in queryCache
if (cachedBindStatus == _BIND_STATUS_ACCEPTED) != bool(accepted):
returnValue(None)
@@ -800,7 +804,7 @@
"""
bindRows = yield cls._bindForNameAndHomeID.on(home._txn, name=name, homeID=home._resourceID)
if bindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = bindRows[0] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = bindRows[0] #@UnusedVariable
if (bindStatus == _BIND_STATUS_ACCEPTED) != bool(accepted):
returnValue(None)
@@ -816,7 +820,7 @@
home._txn, name=name, homeID=home._resourceID
)
if groupBindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = groupBindRows[0] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = groupBindRows[0] #@UnusedVariable
if (bindStatus == _BIND_STATUS_ACCEPTED) != bool(accepted):
returnValue(None)
@@ -831,7 +835,7 @@
if accepted:
returnValue((yield addressbook.objectResourceWithID(resourceID)))
else:
- returnValue((yield AddressBookObject.objectWithID(addressbook, resourceID))) # avoids object cache
+ returnValue((yield AddressBookObject.objectWithID(addressbook, resourceID))) # avoids object cache
returnValue(None)
@@ -855,7 +859,7 @@
home._txn, resourceID=resourceID, homeID=home._resourceID
)
if bindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = bindRows[0] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = bindRows[0] #@UnusedVariable
if (bindStatus == _BIND_STATUS_ACCEPTED) != bool(accepted):
returnValue(None)
@@ -869,7 +873,7 @@
home._txn, homeID=home._resourceID, addressbookID=resourceID
)
if groupBindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = groupBindRows[0] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = groupBindRows[0] #@UnusedVariable
if (bindStatus == _BIND_STATUS_ACCEPTED) != bool(accepted):
returnValue(None)
@@ -910,7 +914,7 @@
rows.extend((yield AddressBookObject._acceptedBindForHomeID.on(
home._txn, homeID=home._resourceID
)))
- for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in rows: #@UnusedVariable
+ for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in rows: #@UnusedVariable
ownerHome = yield home._txn.homeWithResourceID(home._homeType, homeID)
names |= set([ownerHome.shareeAddressBookName()])
returnValue(tuple(names))
@@ -981,7 +985,7 @@
)
readWriteGroupIDs = []
readOnlyGroupIDs = []
- for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in groupBindRows: #@UnusedVariable
+ for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in groupBindRows: #@UnusedVariable
if bindMode == _BIND_MODE_WRITE:
readWriteGroupIDs.append(resourceID)
else:
@@ -1027,7 +1031,7 @@
)
readWriteGroupIDs = []
readOnlyGroupIDs = []
- for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in groupBindRows: #@UnusedVariable
+ for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in groupBindRows: #@UnusedVariable
if bindMode == _BIND_MODE_WRITE:
readWriteGroupIDs.append(resourceID)
else:
@@ -1165,7 +1169,7 @@
bindRows = yield self._sharedBindForResourceID.on(
self._txn, resourceID=self._resourceID, homeID=self._home._resourceID
)
- for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in bindRows: #@UnusedVariable
+ for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in bindRows: #@UnusedVariable
home = yield self._txn.homeWithResourceID(self._home._homeType, homeID)
new = yield home.childWithName(self.shareeAddressBookName())
result.append(new)
@@ -1191,7 +1195,7 @@
bindRows = yield self._unacceptedBindForResourceID.on(
self._txn, resourceID=self._resourceID
)
- for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in bindRows: #@UnusedVariable
+ for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in bindRows: #@UnusedVariable
home = yield self._txn.homeWithResourceID(self._home._homeType, homeID)
new = yield self.objectWithName(home, self.shareeAddressBookName(), accepted=False)
result.append(new)
@@ -1259,7 +1263,7 @@
#_homeChildMetaDataSchema = schema.ADDRESSBOOK_OBJECT
- def __init__(self, addressbook, name, uid, resourceID=None, metadata=None): #@UnusedVariable
+ def __init__(self, addressbook, name, uid, resourceID=None, metadata=None): #@UnusedVariable
self._kind = None
self._ownerAddressBookResourceID = None
@@ -1277,6 +1281,7 @@
def __repr__(self):
return '<%s: %s("%s")>' % (self.__class__.__name__, self._resourceID, self.name())
+
@property
def _addressbook(self):
return self._parentCollection
@@ -1340,7 +1345,7 @@
# add to foreign member table row by UID
memberAddress = "urn:uuid:" + self._uid
for groupID in [groupIDRow[0] for groupIDRow in groupIDRows]:
- if groupID != self._ownerAddressBookResourceID: # no aboForeignMembers on address books
+ if groupID != self._ownerAddressBookResourceID: # no aboForeignMembers on address books
yield Insert(
{aboForeignMembers.GROUP_ID: groupID,
aboForeignMembers.ADDRESSBOOK_ID: self._ownerAddressBookResourceID,
@@ -1394,7 +1399,7 @@
@classproperty
- def _allColumnsWithResourceID(cls): #@NoSelf
+ def _allColumnsWithResourceID(cls): #@NoSelf
obj = cls._objectSchema
return Select(
cls._allColumns, From=obj,
@@ -1412,7 +1417,7 @@
@return: L{self} if object exists in the DB, else C{None}
"""
rows = None
- if self.owned() or self._addressbook.fullyShared(): # owned or fully shared
+ if self.owned() or self._addressbook.fullyShared(): # owned or fully shared
if self._name:
rows = yield self._allColumnsWithParentAndName.on(
self._txn, name=self._name,
@@ -1429,7 +1434,7 @@
parentID=self._parentCollection._resourceID
)
- if not rows and self._addressbook.fullyShared(): # perhaps add special group
+ if not rows and self._addressbook.fullyShared(): # perhaps add special group
if self._name:
if self._name == (yield self._addressbook._groupForEntireAB_Name()):
rows = [(yield self._addressbook._groupForEntireAB_Row())]
@@ -1478,7 +1483,7 @@
)
if groupBindRows:
- bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = groupBindRows[0] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = groupBindRows[0] #@UnusedVariable
self._bindMode = bindMode
self._bindStatus = bindStatus
self._bindMessage = bindMessage
@@ -1492,7 +1497,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.
@@ -1597,7 +1602,7 @@
if self.owned():
# update revision table of the sharee group address book
- if self._kind == _ABO_KIND_GROUP: # optimization
+ if self._kind == _ABO_KIND_GROUP: # optimization
for shareeAddressBook in (yield self.asShared()):
yield self._changeAddressBookRevision(shareeAddressBook, inserting)
# one is enough because all have the same resourceID
@@ -1641,7 +1646,7 @@
@classproperty
- def _insertABObject(cls): #@NoSelf
+ def _insertABObject(cls): #@NoSelf
"""
DAL statement to create an addressbook object with all default values.
"""
@@ -1661,7 +1666,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.
@@ -1678,7 +1683,7 @@
}
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
+ assert inserting or self._kind == kind # can't change kind. Should be checked in upper layers
self._kind = kind
# For shared groups: Non owner may NOT add group members not currently in group!
@@ -1743,7 +1748,7 @@
self._objectText = componentText
uid = component.resourceUID()
- assert inserting or self._uid == uid # can't change UID. Should be checked in upper layers
+ assert inserting or self._uid == uid # can't change UID. Should be checked in upper layers
self._uid = uid
# Special - if migrating we need to preserve the original md5
@@ -1969,7 +1974,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.metadataColumns()
@@ -2005,7 +2010,7 @@
groupBindRows = yield self._sharedBindForResourceID.on(
self._txn, resourceID=self._resourceID, homeID=self._home._resourceID
)
- for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in groupBindRows: #@UnusedVariable
+ for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in groupBindRows: #@UnusedVariable
home = yield self._txn.homeWithResourceID(self._home._homeType, homeID)
addressbook = yield home.childWithName(self._home.shareeAddressBookName())
new = yield addressbook.objectResourceWithID(resourceID)
@@ -2033,19 +2038,19 @@
groupBindRows = yield self._unacceptedBindForResourceID.on(
self._txn, resourceID=self._resourceID
)
- for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in groupBindRows: #@UnusedVariable
+ for bindMode, homeID, resourceID, bindName, bindStatus, bindMessage in groupBindRows: #@UnusedVariable
home = yield self._txn.homeWithResourceID(self._home._homeType, homeID)
addressbook = yield home.childWithName(self._home.shareeAddressBookName())
if not addressbook:
addressbook = yield AddressBook.objectWithName(home, self._home.shareeAddressBookName(), accepted=False)
- new = yield AddressBookObject.objectWithID(addressbook, resourceID) # avoids object cache
+ new = yield AddressBookObject.objectWithID(addressbook, resourceID) # avoids object cache
result.append(new)
returnValue(result)
@classproperty
- def _addressbookIDForResourceID(cls): #@NoSelf
+ def _addressbookIDForResourceID(cls): #@NoSelf
obj = cls._objectSchema
return Select([obj.PARENT_RESOURCE_ID],
From=obj,
@@ -2169,7 +2174,7 @@
groupBindRows = yield self._bindForResourceIDAndHomeID.on(
self._txn, resourceID=self._resourceID, homeID=shareeHome._resourceID
)
- bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = groupBindRows[0] #@UnusedVariable
+ bindMode, homeID, resourceID, bindName, bindStatus, bindMessage = groupBindRows[0] #@UnusedVariable
if bindStatus == _BIND_STATUS_ACCEPTED:
group = yield shareeHome.objectForShareUID(bindName)
else:
@@ -2276,7 +2281,7 @@
@classproperty
- def _acceptedBindWithHomeIDAndAddressBookID(cls): #@NoSelf
+ def _acceptedBindWithHomeIDAndAddressBookID(cls): #@NoSelf
bind = cls._bindSchema
abo = cls._objectSchema
return Select(
@@ -2290,7 +2295,7 @@
@classproperty
- def _unacceptedBindWithHomeIDAndAddressBookID(cls): #@NoSelf
+ def _unacceptedBindWithHomeIDAndAddressBookID(cls): #@NoSelf
bind = cls._bindSchema
abo = cls._objectSchema
return Select(
@@ -2304,7 +2309,7 @@
@classproperty
- def _bindWithHomeIDAndAddressBookID(cls): #@NoSelf
+ def _bindWithHomeIDAndAddressBookID(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/20130322/55a54dbd/attachment-0001.html>
More information about the calendarserver-changes
mailing list