[CalendarServer-changes] [11075] CalendarServer/branches/users/glyph/sharedgroups-2
source_changes at macosforge.org
source_changes at macosforge.org
Fri Apr 19 21:35:02 PDT 2013
Revision: 11075
http://trac.calendarserver.org//changeset/11075
Author: gaya at apple.com
Date: 2013-04-19 21:35:02 -0700 (Fri, 19 Apr 2013)
Log Message:
-----------
Up to 11025
Modified Paths:
--------------
CalendarServer/branches/users/glyph/sharedgroups-2/twistedcaldav/storebridge.py
CalendarServer/branches/users/glyph/sharedgroups-2/txdav/caldav/datastore/test/common.py
CalendarServer/branches/users/glyph/sharedgroups-2/txdav/caldav/datastore/test/test_file.py
CalendarServer/branches/users/glyph/sharedgroups-2/txdav/carddav/datastore/sql.py
CalendarServer/branches/users/glyph/sharedgroups-2/txdav/common/datastore/sql.py
Modified: CalendarServer/branches/users/glyph/sharedgroups-2/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedgroups-2/twistedcaldav/storebridge.py 2013-04-20 03:02:24 UTC (rev 11074)
+++ CalendarServer/branches/users/glyph/sharedgroups-2/twistedcaldav/storebridge.py 2013-04-20 04:35:02 UTC (rev 11075)
@@ -266,7 +266,7 @@
def owner_url(self):
- if self.isShareeCollection():
+ if self.isShareeResource():
return joinURL(self._share.url(), "/")
else:
return self.url()
Modified: CalendarServer/branches/users/glyph/sharedgroups-2/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedgroups-2/txdav/caldav/datastore/test/common.py 2013-04-20 03:02:24 UTC (rev 11074)
+++ CalendarServer/branches/users/glyph/sharedgroups-2/txdav/caldav/datastore/test/common.py 2013-04-20 04:35:02 UTC (rev 11075)
@@ -536,7 +536,6 @@
self.assertEquals(name, "/CalDAV/example.com/home1/")
-
@inlineCallbacks
def test_displayNameNone(self):
"""
@@ -1110,6 +1109,26 @@
@inlineCallbacks
+ def test_sharedNotifierID(self):
+ yield self.test_shareWith()
+ yield self.commit()
+
+ home = yield self.homeUnderTest()
+ self.assertEquals(home.notifierID(), "CalDAV|home1")
+ calendar = yield home.calendarWithName("calendar_1")
+ self.assertEquals(calendar.notifierID(), "CalDAV|home1")
+ self.assertEquals(calendar.notifierID(label="collection"), "CalDAV|home1/calendar_1")
+ yield self.commit()
+
+ home = yield self.homeUnderTest(name=OTHER_HOME_UID)
+ self.assertEquals(home.notifierID(), "CalDAV|%s" % (OTHER_HOME_UID,))
+ calendar = yield home.calendarWithName(self.sharedName)
+ self.assertEquals(calendar.notifierID(), "CalDAV|%s" % (OTHER_HOME_UID,))
+ self.assertEquals(calendar.notifierID(label="collection"), "CalDAV|home1/calendar_1")
+ yield self.commit()
+
+
+ @inlineCallbacks
def test_hasCalendarResourceUIDSomewhereElse(self):
"""
L{ICalendarHome.hasCalendarResourceUIDSomewhereElse} will determine if
Modified: CalendarServer/branches/users/glyph/sharedgroups-2/txdav/caldav/datastore/test/test_file.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedgroups-2/txdav/caldav/datastore/test/test_file.py 2013-04-20 03:02:24 UTC (rev 11074)
+++ CalendarServer/branches/users/glyph/sharedgroups-2/txdav/caldav/datastore/test/test_file.py 2013-04-20 04:35:02 UTC (rev 11075)
@@ -490,6 +490,7 @@
test_asShared = test_shareWith
test_unshareSharerSide = test_shareWith
test_unshareShareeSide = test_shareWith
+ test_sharedNotifierID = test_shareWith
def test_init(self):
Modified: CalendarServer/branches/users/glyph/sharedgroups-2/txdav/carddav/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedgroups-2/txdav/carddav/datastore/sql.py 2013-04-20 03:02:24 UTC (rev 11074)
+++ CalendarServer/branches/users/glyph/sharedgroups-2/txdav/carddav/datastore/sql.py 2013-04-20 04:35:02 UTC (rev 11075)
@@ -262,6 +262,17 @@
returnValue(ownerHome)
+ @inlineCallbacks
+ def ownerHomeAndChildNameForChildID(self, resourceID):
+ """
+ Get the owner home for a shared child ID and the owner's name for that bound child.
+ Subclasses may override.
+ """
+ ownerHome = yield self.ownerHomeWithChildID(resourceID)
+ ownerName = ownerHome.addressbook.name()
+ returnValue((ownerHome, ownerName))
+
+
@classproperty
def _syncTokenQuery(cls): #@NoSelf
"""
@@ -360,6 +371,7 @@
def __init__(self, home, name, resourceID, mode, status, message=None, ownerHome=None, bindName=None):
+ ownerName = ownerHome.addressbook.name() if ownerHome else None
super(AddressBook, self).__init__(home, name, resourceID, mode, status, message=message, ownerHome=ownerHome)
self._index = PostgresLegacyABIndexEmulator(self)
self._bindName = bindName
Modified: CalendarServer/branches/users/glyph/sharedgroups-2/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/glyph/sharedgroups-2/txdav/common/datastore/sql.py 2013-04-20 03:02:24 UTC (rev 11074)
+++ CalendarServer/branches/users/glyph/sharedgroups-2/txdav/common/datastore/sql.py 2013-04-20 04:35:02 UTC (rev 11075)
@@ -2142,14 +2142,14 @@
@inlineCallbacks
- def ownerHomeWithChildID(self, resourceID):
+ def ownerHomeAndChildNameForChildID(self, resourceID):
"""
- Get the owner home for a shared child ID
+ Get the owner home for a shared child ID and the owner's name for that bound child.
Subclasses may override.
"""
- ownerHomeRows = yield self._childClass._ownerHomeWithResourceID.on(self._txn, resourceID=resourceID)
- ownerHome = yield self._txn.homeWithResourceID(self._homeType, ownerHomeRows[0][0])
- returnValue(ownerHome)
+ ownerHomeID, ownerName = (yield self._childClass._ownerHomeWithResourceID.on(self._txn, resourceID=resourceID))[0]
+ ownerHome = yield self._txn.homeWithResourceID(self._homeType, ownerHomeID)
+ returnValue((ownerHome, ownerName))
@@ -2936,14 +2936,8 @@
_revisionsSchema = None
_objectSchema = None
- def __init__(self, home, name, resourceID, mode, status, message=None, ownerHome=None):
- if home._notifiers:
- childID = "%s/%s" % (home.uid(), name)
- notifiers = [notifier.clone(label="collection", id=childID)
- for notifier in home._notifiers]
- else:
- notifiers = None
+ def __init__(self, home, name, resourceID, mode, status, message=None, ownerHome=None, ownerName=None):
self._home = home
self._name = name
@@ -2951,16 +2945,32 @@
self._bindMode = mode
self._bindStatus = status
self._bindMessage = message
+ if status != _BIND_STATUS_ACCEPTED:
+ assert ownerHome
+ assert ownerName
self._ownerHome = home if ownerHome is None else ownerHome
+ self._ownerName = name if ownerName is None else ownerName
+
self._created = None
self._modified = None
self._objects = {}
self._objectNames = None
self._syncTokenRevision = None
- self._notifiers = notifiers
- self._index = None # Derived classes need to set this
+ # Always use notifiers based off the owner home so that shared collections use tokens common
+ # to the owner - and thus will be the same for each sharee. Without that, each sharee would have
+ # a different token to subscribe to and thus would each need a separate push - whereas a common
+ # token only requires one push (to multiple subscribers).
+ if self._ownerHome._notifiers:
+ childID = "%s/%s" % (self._ownerHome.uid(), self._ownerName)
+ self._notifiers = [notifier.clone(label="collection", id=childID)
+ for notifier in self._ownerHome._notifiers]
+ else:
+ self._notifiers = None
+ self._index = None # Derived classes need to set this
+
+
def memoMe(self, key, memo): #@UnusedVariable
"""
Add this object to the memo dictionary in whatever fashion is appropriate.
@@ -3021,15 +3031,17 @@
if bindStatus == _BIND_MODE_OWN:
ownerHome = home
+ ownerName = bindName
else:
#TODO: get all ownerHomeIDs at once
- ownerHome = yield home.ownerHomeWithChildID(resourceID)
+ ownerHome, ownerName = yield home.ownerHomeAndChildNameForChildID(resourceID)
child = cls(
home=home,
name=bindName, resourceID=resourceID,
mode=bindMode, status=bindStatus,
- message=bindMessage, ownerHome=ownerHome
+ message=bindMessage, ownerHome=ownerHome,
+ ownerName=ownerName,
)
for attr, value in zip(cls.metadataAttributes(), metadata):
setattr(child, attr, value)
@@ -3085,14 +3097,16 @@
if bindMode == _BIND_MODE_OWN:
ownerHome = home
+ ownerName = bindName
else:
- ownerHome = yield home.ownerHomeWithChildID(resourceID)
+ ownerHome, ownerName = yield home.ownerHomeAndChildNameForChildID(resourceID)
child = cls(
home=home,
name=name, resourceID=resourceID,
mode=bindMode, status=bindStatus,
message=bindMessage, ownerHome=ownerHome,
+ ownerName=ownerName
)
yield child.initFromStore()
returnValue(child)
@@ -3350,15 +3364,16 @@
@classproperty
def _ownerHomeWithResourceID(cls): #@NoSelf
"""
- DAL query to retrieve the home resource ID of the owner from the bound
+ DAL query to retrieve the home resource ID and resource name of the owner from the bound
home-child ID.
"""
bind = cls._bindSchema
- return Select([bind.HOME_RESOURCE_ID],
- From=bind,
- Where=(bind.RESOURCE_ID ==
- Parameter("resourceID")).And(
- bind.BIND_MODE == _BIND_MODE_OWN))
+ return Select(
+ [bind.HOME_RESOURCE_ID, bind.RESOURCE_NAME, ],
+ From=bind,
+ Where=(bind.RESOURCE_ID == Parameter("resourceID")).And(
+ bind.BIND_MODE == _BIND_MODE_OWN)
+ )
@inlineCallbacks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130419/929a1bd1/attachment-0001.html>
More information about the calendarserver-changes
mailing list