[CalendarServer-changes] [9713] CalendarServer/branches/users/gaya/inviteclean

source_changes at macosforge.org source_changes at macosforge.org
Thu Aug 16 12:46:25 PDT 2012


Revision: 9713
          http://trac.macosforge.org/projects/calendarserver/changeset/9713
Author:   gaya at apple.com
Date:     2012-08-16 12:46:22 -0700 (Thu, 16 Aug 2012)
Log Message:
-----------
Remove SharedCollectionResource, set/isVirtualShare.  Use set/isShareeCollection instead. Use db property store to access shadowned/global/per-user resources.

Modified Paths:
--------------
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/method/put_common.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/schedule.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/storebridge.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_link.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_resource.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_schedule.py
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_sharing.py
    CalendarServer/branches/users/gaya/inviteclean/txdav/base/propertystore/sql.py
    CalendarServer/branches/users/gaya/inviteclean/txdav/base/propertystore/test/test_sql.py
    CalendarServer/branches/users/gaya/inviteclean/txdav/common/datastore/sql.py
    CalendarServer/branches/users/gaya/inviteclean/txdav/common/icommondatastore.py

Removed Paths:
-------------
    CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharedcollection.py

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/method/put_common.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/method/put_common.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/method/put_common.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -764,9 +764,9 @@
         Make sure sharees only use dropbox paths of the sharer.
         """
         
-        # Only relevant if calendar is virtual share
+        # Only relevant if calendar is sharee collection
         changed = False
-        if self.destinationparent.isVirtualShare():
+        if self.destinationparent.isShareeCollection():
             
             # Get all X-APPLE-DROPBOX's and ATTACH's that are http URIs
             xdropboxes = self.calendar.getAllPropertiesInAnyComponent(
@@ -838,7 +838,7 @@
             return False
         
         # Never add default alarms to calendar data in shared calendars
-        if self.destinationparent.isVirtualShare():
+        if self.destinationparent.isShareeCollection():
             return False
 
         # Add default alarm for VEVENT and VTODO only
@@ -956,8 +956,8 @@
             if do_implicit_action and self.allowImplicitSchedule:
 
                 # Cannot do implicit in sharee's shared calendar
-                isvirt = self.destinationparent.isVirtualShare()
-                if isvirt:
+                isShareeCollection = self.destinationparent.isShareeCollection()
+                if isShareeCollection:
                     raise HTTPError(ErrorResponse(
                         responsecode.FORBIDDEN,
                         (calendarserver_namespace, "sharee-privilege-needed",),

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/resource.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -69,7 +69,7 @@
 from twistedcaldav.datafilters.privateevents import PrivateEventFilter
 from twistedcaldav.directory.internal import InternalDirectoryRecord
 from twistedcaldav.extensions import DAVResource, DAVPrincipalResource,\
-    PropertyNotFoundError, DAVResourceWithChildrenMixin
+    DAVResourceWithChildrenMixin
 from twistedcaldav.ical import Component
 
 from twistedcaldav.icaldav import ICalDAVResource, ICalendarPrincipalResource
@@ -488,13 +488,13 @@
         Need to special case schedule-calendar-transp for backwards compatability.
         """
         
+        '''
         if type(property) is tuple:
             qname = property
         else:
             qname = property.qname()
-
-        isvirt = self.isVirtualShare()
-        if isvirt:
+        isShareeCollection = self.isShareeCollection()
+        if isShareeCollection:
             if self.isShadowableProperty(qname):
                 p = self.deadProperties().contains(qname)
                 if p:
@@ -503,6 +503,7 @@
             elif (not self.isGlobalProperty(qname)):
                 result = self._hasSharedProperty(qname, request)
                 returnValue(result)
+        '''
 
         res = (yield self._hasGlobalProperty(property, request))
         returnValue(res)
@@ -545,8 +546,6 @@
         else:
             qname = property.qname()
 
-        isvirt = self.isVirtualShare()
-
         if self.isCalendarCollection() or self.isAddressBookCollection():
 
             # Push notification DAV property "pushkey"
@@ -558,7 +557,7 @@
                 if hasattr(self, "_newStoreObject"):
                     dataObject = getattr(self, "_newStoreObject")
                 if dataObject:
-                    label = "collection" if isvirt else "default"
+                    label = "collection" if self.isShareeCollection() else "default"
                     nodeName = (yield dataObject.nodeName(label=label))
                     if nodeName:
                         propVal = customxml.PubSubXMPPPushKeyProperty(nodeName)
@@ -566,8 +565,9 @@
 
                 returnValue(customxml.PubSubXMPPPushKeyProperty())
 
-
-        if isvirt:
+        '''
+        isShareeCollection = self.isShareeCollection()
+        if isShareeCollection:
             if self.isShadowableProperty(qname):
                 try:
                     p = self.deadProperties().get(qname)
@@ -578,6 +578,7 @@
             elif (not self.isGlobalProperty(qname)):
                 result = self._readSharedProperty(qname, request)
                 returnValue(result)
+        '''
 
         res = (yield self._readGlobalProperty(qname, property, request))
         returnValue(res)
@@ -698,9 +699,9 @@
                 returnValue(customxml.AllowedSharingModes(customxml.CanBeShared()))
 
         elif qname == customxml.SharedURL.qname():
-            isvirt = self.isVirtualShare()
+            isShareeCollection = self.isShareeCollection()
             
-            if isvirt:
+            if isShareeCollection:
                 returnValue(customxml.SharedURL(element.HRef.fromString(self._share.url())))
             else:
                 returnValue(None)
@@ -715,8 +716,9 @@
         )
         
         # Per-user Dav props currently only apply to a sharee's copy of a calendar
-        isvirt = self.isVirtualShare()
-        if isvirt and (self.isShadowableProperty(property.qname()) or (not self.isGlobalProperty(property.qname()))):
+        isShareeCollection = self.isShareeCollection()
+
+        if isShareeCollection and (self.isShadowableProperty(property.qname()) or (not self.isGlobalProperty(property.qname()))):
             yield self._preProcessWriteProperty(property, request, isShare=True)
             p = self.deadProperties().set(property)
             returnValue(p)
@@ -870,8 +872,8 @@
     def accessControlList(self, request, *args, **kwargs):
 
         acls = None
-        isvirt = self.isVirtualShare()
-        if isvirt:
+        isShareeCollection = self.isShareeCollection()
+        if isShareeCollection:
             acls = (yield self.shareeAccessControlList(request, *args, **kwargs))
 
         if acls is None:
@@ -926,8 +928,8 @@
         Return the DAV:owner property value (MUST be a DAV:href or None).
         """
 
-        isVirt = self.isVirtualShare()
-        if isVirt:
+        isShareeCollection = self.isShareeCollection()
+        if isShareeCollection:
             parent = (yield self.locateParent(request, self._share.url()))
         else:
             parent = (yield self.locateParent(request, request.urlForResource(self)))
@@ -942,8 +944,8 @@
         """
         Return the DAV:owner property value (MUST be a DAV:href or None).
         """
-        isVirt = self.isVirtualShare()
-        if isVirt:
+        isShareeCollection = self.isShareeCollection()
+        if isShareeCollection:
             parent = (yield self.locateParent(request, self._share.url()))
         else:
             parent = (yield self.locateParent(request, request.urlForResource(self)))
@@ -960,14 +962,18 @@
         This is the owner of the resource based on the URI used to access it. For a shared
         collection it will be the sharee, otherwise it will be the regular the ownerPrincipal.
         """
-
-        isVirt = self.isVirtualShare()
-        if isVirt:
+        '''
+        isShareeCollection = self.isShareeCollection()
+        if isShareeCollection:
             returnValue(self._shareePrincipal)
         else:
             parent = (yield self.locateParent(
                 request, request.urlForResource(self)
             ))
+        '''
+        parent = (yield self.locateParent(
+            request, request.urlForResource(self)
+        ))
         if parent and isinstance(parent, CalDAVResource):
             result = (yield parent.resourceOwnerPrincipal(request))
             returnValue(result)
@@ -1357,16 +1363,16 @@
         """
 
         sharedParent = None
-        isvirt = self.isVirtualShare()
-        if isvirt:
-            # A virtual share's quota root is the resource owner's root
+        isShareeCollection = self.isShareeCollection()
+        if isShareeCollection:
+            # A sharee collection's quota root is the resource owner's root
             sharedParent = (yield request.locateResource(parentForURL(self._share.url())))
         else:
             parent = (yield self.locateParent(request, request.urlForResource(self)))
             if isCalendarCollectionResource(parent) or isAddressBookCollectionResource(parent):
-                isvirt = parent.isVirtualShare()
-                if isvirt:
-                    # A virtual share's quota root is the resource owner's root
+                isShareeCollection = parent.isShareeCollection()
+                if isShareeCollection:
+                    # A sharee collection's quota root is the resource owner's root
                     sharedParent = (yield request.locateResource(parentForURL(parent._share.url())))
 
         if sharedParent:
@@ -2221,12 +2227,18 @@
 
         # Try normal child type
         child = (yield self.makeRegularChild(name))
-
+        
+        '''
         # Try shares next if child does not exist
         if not child.exists() and self.canShare():
             sharedchild = yield self.provisionShare(name)
             if sharedchild:
                 returnValue(sharedchild)
+        '''
+                    
+        share = yield self.shareWithChild(child._newStoreObject)
+        if share:
+            child.setShareeCollection(share)
 
         returnValue(child)
 
@@ -2578,7 +2590,7 @@
     @inlineCallbacks
     def makeRegularChild(self, name):
         newCalendar = yield self._newStoreHome.calendarWithName(name)
-        if newCalendar and not newCalendar.owned():
+        if newCalendar and not newCalendar.owned() and not self.canShare():
             newCalendar = None
 
         from twistedcaldav.storebridge import CalendarCollectionResource
@@ -2763,7 +2775,7 @@
             if defaultAddressBookProperty and len(defaultAddressBookProperty.children) == 1:
                 defaultAddressBook = str(defaultAddressBookProperty.children[0])
                 adbk = (yield request.locateResource(str(defaultAddressBook)))
-                if adbk is not None and isAddressBookCollectionResource(adbk) and adbk.exists() and not adbk.isVirtualShare():
+                if adbk is not None and isAddressBookCollectionResource(adbk) and adbk.exists() and not adbk.isShareeCollection():
                     returnValue(defaultAddressBookProperty) 
             
             # Default is not valid - we have to try to pick one
@@ -2785,7 +2797,7 @@
             if len(new_adbk) == 1:
                 adbkURI = str(new_adbk[0])
                 adbk = (yield request.locateResource(str(new_adbk[0])))
-            if adbk is None or not adbk.exists() or not isAddressBookCollectionResource(adbk) or adbk.isVirtualShare():
+            if adbk is None or not adbk.exists() or not isAddressBookCollectionResource(adbk) or adbk.isShareeCollection():
                 # Validate that href's point to a valid addressbook.
                 raise HTTPError(ErrorResponse(
                     responsecode.CONFLICT,
@@ -2831,7 +2843,7 @@
                 mainCls = GlobalAddressBookCollectionResource
 
         newAddressBook = yield self._newStoreHome.addressbookWithName(name)
-        if newAddressBook and not newAddressBook.owned():
+        if newAddressBook and not newAddressBook.owned() and not self.canShare():
             newAddressBook = None
         similar = mainCls(
             newAddressBook, self, name,

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/schedule.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/schedule.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/schedule.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -245,7 +245,7 @@
         if defaultCalendarProperty and len(defaultCalendarProperty.children) == 1:
             defaultCalendar = str(defaultCalendarProperty.children[0])
             cal = (yield request.locateResource(str(defaultCalendar)))
-            if cal is not None and isCalendarCollectionResource(cal) and cal.exists() and not cal.isVirtualShare():
+            if cal is not None and isCalendarCollectionResource(cal) and cal.exists() and not cal.isShareeCollection():
                 returnValue(defaultCalendarProperty) 
         
         # Default is not valid - we have to try to pick one
@@ -272,7 +272,7 @@
 
         # TODO: check that owner of the new calendar is the same as owner of this inbox
         if cal is None or not cal.exists() or not isCalendarCollectionResource(cal) or \
-            cal.isVirtualShare() or not cal.isSupportedComponent(componentType):
+            cal.isShareeCollection() or not cal.isSupportedComponent(componentType):
             # Validate that href's point to a valid calendar.
             raise HTTPError(ErrorResponse(
                 responsecode.CONFLICT,

Deleted: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharedcollection.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharedcollection.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharedcollection.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -1,62 +0,0 @@
-##
-# Copyright (c) 2010 Apple Inc. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##
-
-__all__ = [
-    "SharedCollectionResource",
-]
-
-from twext.web2.http import HTTPError, StatusResponse
-from twext.web2 import responsecode
-
-from twisted.internet.defer import inlineCallbacks, returnValue
-
-from twistedcaldav.linkresource import LinkResource
-
-
-"""
-Sharing behavior
-"""
-
-class SharedCollectionResource(LinkResource):
-    """
-    This is similar to a LinkResource except that we locate our shared collection resource dynamically.
-    """
-    
-    def __init__(self, parent, share):
-        self.share = share
-        super(SharedCollectionResource, self).__init__(parent, self.share.url())
-
-    @inlineCallbacks
-    def linkedResource(self, request):
-        """
-        Resolve the share host url to the underlying resource (set to be a virtual share).
-        """
-        
-        if not hasattr(self, "_linkedResource"):
-            self._linkedResource = (yield request.locateResource(self.share.url()))
-            
-            if self._linkedResource is not None:
-                # FIXME: this is awkward - because we are "mutating" this object into a virtual share
-                # we must not cache the resource at this URL, otherwise an access of the owner's resource
-                # will return the same virtually shared one which would be wrong.
-                request._forgetResource(self._linkedResource, self.share.url())
-    
-                ownerPrincipal = (yield self.parent.ownerPrincipal(request))
-                self._linkedResource.setVirtualShare(ownerPrincipal, self.share)
-            else:
-                raise HTTPError(StatusResponse(responsecode.NOT_FOUND, "Missing link target: %s" % (self.linkURL,)))
-
-        returnValue(self._linkedResource)

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/sharing.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -93,7 +93,7 @@
                 ))
                 
             # See if it is on the sharee calendar
-            if self.isVirtualShare():
+            if self.isShareeCollection():
                 original = (yield request.locateResource(self._share.url()))
                 yield original.validateInvites()
                 invitations = yield original._allInvitations()
@@ -235,29 +235,26 @@
         returnValue((yield self.isSpecialCollection(customxml.SharedOwner)))
 
 
-    def setVirtualShare(self, shareePrincipal, share):
-        self._isVirtualShare = True
-        self._shareePrincipal = shareePrincipal
+    def setShareeCollection(self, share):
+        self._isShareeCollection = True
         self._share = share
 
-        if hasattr(self, "_newStoreObject"):
-            self._newStoreObject.setSharingUID(self._shareePrincipal.principalUID())
 
+    def isShareeCollection(self):
+        """ Return True if this is a sharee shared calendar collection """
+        return hasattr(self, "_isShareeCollection")
 
-    def isVirtualShare(self):
-        """ Return True if this is a shared calendar collection """
-        return hasattr(self, "_isVirtualShare")
 
-
     @inlineCallbacks
-    def removeVirtualShare(self, request):
-        """ Return True if this is a shared calendar collection """
+    def removeShareeCollection(self, request):
         
+        sharee = self.principalForUID(self._share.shareeUID())
+
         # Remove from sharee's calendar/address book home
         if self.isCalendarCollection():
-            shareeHome = yield self._shareePrincipal.calendarHome(request)
+            shareeHome = yield sharee.calendarHome(request)
         elif self.isAddressBookCollection():
-            shareeHome = yield self._shareePrincipal.addressBookHome(request)
+            shareeHome = yield sharee.addressBookHome(request)
         returnValue((yield shareeHome.removeShare(request, self._share)))
 
 
@@ -270,8 +267,8 @@
         else:
             rtype = superMethod()
 
-        isVirt = self.isVirtualShare()
-        if isVirt:
+        isShareeCollection = self.isShareeCollection()
+        if isShareeCollection:
             rtype = element.ResourceType(
                 *(
                     tuple([child for child in rtype.children if child.qname() != customxml.SharedOwner.qname()]) + 
@@ -297,10 +294,12 @@
     @inlineCallbacks
     def shareeAccessControlList(self, request, *args, **kwargs):
 
-        assert self._isVirtualShare, "Only call this for a virtual share"
+        assert self._isShareeCollection, "Only call this for a sharee collection"
 
         wikiAccessMethod = kwargs.get("wikiAccessMethod", getWikiAccess)
 
+        sharee = self.principalForUID(self._share.shareeUID())
+
         # Direct shares use underlying privileges of shared collection
         if self._share.direct():
             original = (yield request.locateResource(self._share.url()))
@@ -308,7 +307,7 @@
             if owner.record.recordType == WikiDirectoryService.recordType_wikis:
                 # Access level comes from what the wiki has granted to the
                 # sharee
-                userID = self._shareePrincipal.record.guid
+                userID = sharee.record.guid
                 wikiID = owner.record.shortNames[0]
                 access = (yield wikiAccessMethod(userID, wikiID))
                 if access == "read":
@@ -352,7 +351,7 @@
         aces = (
             # Inheritable specific access for the resource's associated principal.
             element.ACE(
-                element.Principal(element.HRef(self._shareePrincipal.principalURL())),
+                element.Principal(element.HRef(sharee.principalURL())),
                 element.Grant(*userprivs),
                 element.Protected(),
                 TwistedACLInheritable(),
@@ -379,7 +378,7 @@
             aces += (
                 # DAV:read/DAV:read-current-user-privilege-set access for this principal's calendar-proxy-read users.
                 element.ACE(
-                    element.Principal(element.HRef(joinURL(self._shareePrincipal.principalURL(), "calendar-proxy-read/"))),
+                    element.Principal(element.HRef(joinURL(sharee.principalURL(), "calendar-proxy-read/"))),
                     element.Grant(
                         element.Privilege(element.Read()),
                         element.Privilege(element.ReadCurrentUserPrivilegeSet()),
@@ -389,7 +388,7 @@
                 ),
                 # DAV:read/DAV:read-current-user-privilege-set/DAV:write access for this principal's calendar-proxy-write users.
                 element.ACE(
-                    element.Principal(element.HRef(joinURL(self._shareePrincipal.principalURL(), "calendar-proxy-write/"))),
+                    element.Principal(element.HRef(joinURL(sharee.principalURL(), "calendar-proxy-write/"))),
                     element.Grant(*proxyprivs),
                     element.Protected(),
                     TwistedACLInheritable(),
@@ -1073,21 +1072,7 @@
     manipulating a sharee's set of shared calendars.
     """
 
-
     @inlineCallbacks
-    def provisionShare(self, name):
-        child = yield self._newStoreHome.childWithName(name)
-        share = yield self.shareWithChild(child)
-        if share:
-            from twistedcaldav.sharedcollection import SharedCollectionResource
-            sharedCollection = SharedCollectionResource(self, share)
-            self.putChild(name, sharedCollection)
-            returnValue(sharedCollection)
-        
-        returnValue(None)
-
-
-    @inlineCallbacks
     def shareWithChild(self, child, request=None):
         # Try to find a matching share
         if not child or child.owned():
@@ -1095,6 +1080,7 @@
         
         sharerHomeID = yield child.sharerHomeID()
         sharerHome = yield self._newStoreHome._txn.homeWithResourceID(self._newStoreHome._homeType, sharerHomeID)
+        #FIXME: sharerHome = child.ownerHome() when it works
         sharerHomeChild = yield sharerHome.childWithID(child._resourceID)
         
         # get the shared object's URL
@@ -1102,8 +1088,8 @@
         
         if not request:
             # FIXEME:  Fake up a request that can be used to get the sharer home resource
-            class FakeRequest(object):pass
-            fakeRequest = FakeRequest()
+            class _FakeRequest(object):pass
+            fakeRequest = _FakeRequest()
             setattr(fakeRequest, TRANSACTION_KEY, self._newStoreHome._txn)
             request = fakeRequest
         
@@ -1179,7 +1165,6 @@
 
         # Get shared collection in non-share mode first
         sharedCollection = yield request.locateResource(share.url())
-        ownerPrincipal = yield self.ownerPrincipal(request)
 
         # For a direct share we will copy any calendar-color over using the owners view
         color = None
@@ -1188,21 +1173,29 @@
                 color = (yield sharedCollection.readProperty(customxml.CalendarColor, request))
             except HTTPError:
                 pass
-        
+            
+        sharee = self.principalForUID(share.shareeUID())
+        if sharedCollection.isCalendarCollection():
+            shareeHomeResource = yield sharee.calendarHome(request)
+        elif sharedCollection.isAddressBookCollection():
+            shareeHomeResource = yield sharee.addressBookHome(request)
+        shareeURL = joinURL(shareeHomeResource.url(), share.name())
+        shareeCollection = yield request.locateResource(shareeURL)
+        shareeCollection.setShareeCollection(share)
+
         # Set per-user displayname or color to whatever was given
-        sharedCollection.setVirtualShare(ownerPrincipal, share)
         if displayname:
-            yield sharedCollection.writeProperty(element.DisplayName.fromString(displayname), request)
+            yield shareeCollection.writeProperty(element.DisplayName.fromString(displayname), request)
         if color:
-            yield sharedCollection.writeProperty(customxml.CalendarColor.fromString(color), request)
+            yield shareeCollection.writeProperty(customxml.CalendarColor.fromString(color), request)
 
         # Calendars always start out transparent and with empty default alarms
-        if isNewShare and sharedCollection.isCalendarCollection():
-            yield sharedCollection.writeProperty(caldavxml.ScheduleCalendarTransp(caldavxml.Transparent()), request)
-            yield sharedCollection.writeProperty(caldavxml.DefaultAlarmVEventDateTime.fromString(""), request)
-            yield sharedCollection.writeProperty(caldavxml.DefaultAlarmVEventDate.fromString(""), request)
-            yield sharedCollection.writeProperty(caldavxml.DefaultAlarmVToDoDateTime.fromString(""), request)
-            yield sharedCollection.writeProperty(caldavxml.DefaultAlarmVToDoDate.fromString(""), request)
+        if isNewShare and shareeCollection.isCalendarCollection():
+            yield shareeCollection.writeProperty(caldavxml.ScheduleCalendarTransp(caldavxml.Transparent()), request)
+            yield shareeCollection.writeProperty(caldavxml.DefaultAlarmVEventDateTime.fromString(""), request)
+            yield shareeCollection.writeProperty(caldavxml.DefaultAlarmVEventDate.fromString(""), request)
+            yield shareeCollection.writeProperty(caldavxml.DefaultAlarmVToDoDateTime.fromString(""), request)
+            yield shareeCollection.writeProperty(caldavxml.DefaultAlarmVToDoDate.fromString(""), request)
  
         # Notify client of changes
         yield self.notifyChanged()
@@ -1403,6 +1396,9 @@
     def summary(self):
         return self._shareeHomeChild.shareMessage()
 
+    def shareeUID(self):
+        return self._shareeHomeChild._home.uid()
+
 class SharedCollectionsDatabase(AbstractSQLDatabase, LoggingMixIn):
     
     db_basename = db_prefix + "shares"

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/storebridge.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/storebridge.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/storebridge.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -97,7 +97,6 @@
         return PropertyName(namespace, name)
 
 
-    # FIXME 'uid' here should be verifying something.
     def get(self, qname):
         try:
             return self._newPropertyStore[self._convertKey(qname)]
@@ -421,11 +420,11 @@
         @rtype: something adaptable to L{twext.web2.iweb.IResponse}
         """
 
-        # Check virtual share first
-        isVirtual = self.isVirtualShare()
-        if isVirtual:
+        # Check sharee collection first
+        isShareeCollection = self.isShareeCollection()
+        if isShareeCollection:
             log.debug("Removing shared collection %s" % (self,))
-            yield self.removeVirtualShare(request)
+            yield self.removeShareeCollection(request)
             returnValue(NO_CONTENT)
 
         log.debug("Deleting collection %s" % (self,))

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_link.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_link.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_link.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -22,7 +22,6 @@
 
 from twistedcaldav.linkresource import LinkResource
 from twistedcaldav.resource import CalendarHomeResource
-from twistedcaldav.sharedcollection import SharedCollectionResource
 from twistedcaldav.test.util import TestCase
 
 
@@ -95,31 +94,3 @@
             self.assertEqual(e.response.code, responsecode.LOOP_DETECTED)
         else:
             self.fail("HTTPError exception not raised")
-
-class SharedCollectionResourceTests(TestCase):
-
-    @inlineCallbacks
-    def test_okLink(self):
-        resource = StubCalendarHomeResource(self.site.resource, "home", object(), StubHome())
-        self.site.resource.putChild("home", resource)
-        link = SharedCollectionResource(resource, StubShare("/home/outbox/"))
-        resource.putChild("link", link)
-
-        request = SimpleRequest(self.site, "GET", "/home/link/")
-        linked_to, _ignore = (yield resource.locateChild(request, ["link",]))
-        self.assertTrue(linked_to is resource.getChild("outbox"))
-
-    @inlineCallbacks
-    def test_badLink(self):
-        resource = CalendarHomeResource(self.site.resource, "home", object(), StubHome())
-        self.site.resource.putChild("home", resource)
-        link = SharedCollectionResource(resource, StubShare("/home/outbox/abc"))
-        resource.putChild("link", link)
-
-        request = SimpleRequest(self.site, "GET", "/home/link/")
-        try:
-            yield resource.locateChild(request, ["link",])
-        except HTTPError, e:
-            self.assertEqual(e.response.code, responsecode.NOT_FOUND)
-        else:
-            self.fail("HTTPError exception not raised")

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_resource.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_resource.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_resource.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -326,8 +326,8 @@
         else:
             self.assertEqual(str(default.children[0]), "/addressbooks/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/newadbk/")
         
-        # Force the new calendar to think it is a virtual share
-        newadbk._isVirtualShare = True
+        # Force the new calendar to think it is a sharee collection
+        newadbk._isShareeCollection = True
         
         try:
             default = yield home.readProperty(carddavxml.DefaultAddressBookURL, request)

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_schedule.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_schedule.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_schedule.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -372,8 +372,8 @@
         else:
             self.assertEqual(str(default.children[0]), "/calendars/__uids__/6423F94A-6B76-4A3A-815B-D52CFD77935D/newcalendar")
         
-        # Force the new calendar to think it is a virtual share
-        newcalendar._isVirtualShare = True
+        # Force the new calendar to think it is a sharee collection
+        newcalendar._isShareeCollection = True
         
         try:
             default = yield inbox.readProperty(caldavxml.ScheduleDefaultCalendarURL, request)

Modified: CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_sharing.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_sharing.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/twistedcaldav/test/test_sharing.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -140,7 +140,7 @@
         
         isShared = (yield self.resource.isShared(request))
         self.assertTrue(isShared)
-        isVShared = self.resource.isVirtualShare()
+        isVShared = self.resource.isShareeCollection()
         self.assertFalse(isVShared)
 
     @inlineCallbacks
@@ -161,7 +161,7 @@
         
         isShared = (yield self.resource.isShared(request))
         self.assertTrue(isShared)
-        isVShared = self.resource.isVirtualShare()
+        isVShared = self.resource.isShareeCollection()
         self.assertFalse(isVShared)
 
     @inlineCallbacks
@@ -182,7 +182,7 @@
         
         isShared = (yield self.resource.isShared(None))
         self.assertFalse(isShared)
-        isVShared = self.resource.isVirtualShare()
+        isVShared = self.resource.isShareeCollection()
         self.assertFalse(isVShared)
 
     @inlineCallbacks
@@ -213,7 +213,7 @@
         
         isShared = (yield self.resource.isShared(None))
         self.assertTrue(isShared)
-        isVShared = self.resource.isVirtualShare()
+        isVShared = self.resource.isShareeCollection()
         self.assertFalse(isVShared)
 
     @inlineCallbacks
@@ -243,7 +243,7 @@
         
         isShared = (yield self.resource.isShared(None))
         self.assertTrue(isShared)
-        isVShared = (yield self.resource.isVirtualShare())
+        isVShared = (yield self.resource.isShareeCollection())
         self.assertFalse(isVShared)
 
     @inlineCallbacks
@@ -560,7 +560,7 @@
 
         class StubCollection(object):
             def __init__(self):
-                self._isVirtualShare = True
+                self._isShareeCollection = True
                 self._shareePrincipal = StubUserPrincipal()
             def isCalendarCollection(self):
                 return True
@@ -575,8 +575,13 @@
             def uid(self):
                 return "012345"
 
+            def shareeUID(self):
+                return StubUserPrincipal().record.guid
+
         class TestCollection(SharedCollectionMixin, StubCollection):
-            pass
+            def principalForUID(self, uid):
+                principal = StubUserPrincipal()
+                return principal if principal.record.guid == uid else None
 
         class StubRecord(object):
             def __init__(self, recordType, name, guid):

Modified: CalendarServer/branches/users/gaya/inviteclean/txdav/base/propertystore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/txdav/base/propertystore/sql.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/txdav/base/propertystore/sql.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -73,13 +73,13 @@
 
     @classmethod
     @inlineCallbacks
-    def load(cls, defaultuser, txn, resourceID, created=False, notifyCallback=None):
+    def load(cls, defaultuser, shareUser, txn, resourceID, created=False, notifyCallback=None):
         """
         @param notifyCallback: a callable used to trigger notifications when the
             property store changes.
         """
         self = cls.__new__(cls)
-        super(PropertyStore, self).__init__(defaultuser)
+        super(PropertyStore, self).__init__(defaultuser, shareUser)
         self._txn = txn
         self._resourceID = resourceID
         self._cached = {}

Modified: CalendarServer/branches/users/gaya/inviteclean/txdav/base/propertystore/test/test_sql.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/txdav/base/propertystore/test/test_sql.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/txdav/base/propertystore/test/test_sql.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -48,10 +48,9 @@
         self.addCleanup(self.maybeCommitLast)
         self._txn = self.store.newTransaction()
         self.propertyStore = self.propertyStore1 = yield PropertyStore.load(
-            "user01", self._txn, 1
+            "user01", None, self._txn, 1
         )
-        self.propertyStore2 = yield PropertyStore.load("user01", self._txn, 1)
-        self.propertyStore2._setPerUserUID("user02")
+        self.propertyStore2 = yield PropertyStore.load("user01", "user02", self._txn, 1)
 
 
     @inlineCallbacks
@@ -74,14 +73,13 @@
 
         store = self.propertyStore1
         self.propertyStore = self.propertyStore1 = yield PropertyStore.load(
-            "user01", self._txn, 1
+            "user01", None, self._txn, 1
         )
         self.propertyStore1._shadowableKeys = store._shadowableKeys
         self.propertyStore1._globalKeys = store._globalKeys
 
         store = self.propertyStore2
-        self.propertyStore2 = yield PropertyStore.load("user01", self._txn, 1)
-        self.propertyStore2._setPerUserUID("user02")
+        self.propertyStore2 = yield PropertyStore.load("user01", "user02", self._txn, 1)
         self.propertyStore2._shadowableKeys = store._shadowableKeys
         self.propertyStore2._globalKeys = store._globalKeys
 
@@ -96,14 +94,13 @@
 
         store = self.propertyStore1
         self.propertyStore = self.propertyStore1 = yield PropertyStore.load(
-            "user01", self._txn, 1
+            "user01", None, self._txn, 1
         )
         self.propertyStore1._shadowableKeys = store._shadowableKeys
         self.propertyStore1._globalKeys = store._globalKeys
 
         store = self.propertyStore2
-        self.propertyStore2 = yield PropertyStore.load("user01", self._txn, 1)
-        self.propertyStore2._setPerUserUID("user02")
+        self.propertyStore2 = yield PropertyStore.load("user01", "user02", self._txn, 1)
         self.propertyStore2._shadowableKeys = store._shadowableKeys
         self.propertyStore2._globalKeys = store._globalKeys
 
@@ -127,7 +124,7 @@
                 pass
         self.addCleanup(maybeAbortIt)
         concurrentPropertyStore = yield PropertyStore.load(
-            "user01", concurrentTxn, 1
+            "user01", None, concurrentTxn, 1
         )
         concurrentPropertyStore[pname] = pval1
         race = []
@@ -155,9 +152,8 @@
     def test_copy(self):
 
         # Existing store
-        store1_user1 = yield PropertyStore.load("user01", self._txn, 2)
-        store1_user2 = yield PropertyStore.load("user01", self._txn, 2)
-        store1_user2._setPerUserUID("user02")
+        store1_user1 = yield PropertyStore.load("user01", None, self._txn, 2)
+        store1_user2 = yield PropertyStore.load("user01", "user02", self._txn, 2)
 
         # Populate current store with data
         props_user1 = (
@@ -179,20 +175,18 @@
         self._txn = self.store.newTransaction()
 
         # Existing store
-        store1_user1 = yield PropertyStore.load("user01", self._txn, 2)
+        store1_user1 = yield PropertyStore.load("user01", None, self._txn, 2)
 
         # New store
-        store2_user1 = yield PropertyStore.load("user01", self._txn, 3)
+        store2_user1 = yield PropertyStore.load("user01", None, self._txn, 3)
 
         # Do copy and check results
         yield store2_user1.copyAllProperties(store1_user1)
         
         self.assertEqual(store1_user1.keys(), store2_user1.keys())
 
-        store1_user2 = yield PropertyStore.load("user01", self._txn, 2)
-        store1_user2._setPerUserUID("user02")
-        store2_user2 = yield PropertyStore.load("user01", self._txn, 3)
-        store2_user2._setPerUserUID("user02")
+        store1_user2 = yield PropertyStore.load("user01", "user02", self._txn, 2)
+        store2_user2 = yield PropertyStore.load("user01", "user02", self._txn, 3)
         self.assertEqual(store1_user2.keys(), store2_user2.keys())
 
 

Modified: CalendarServer/branches/users/gaya/inviteclean/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/txdav/common/datastore/sql.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/txdav/common/datastore/sql.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -82,7 +82,6 @@
 from twistedcaldav.customxml import NotificationType
 from twistedcaldav.dateops import datetimeMktime, parseSQLTimestamp,\
     pyCalendarTodatetime
-#from txdav.xml.rfc2518 import DisplayName
 
 from txdav.base.datastore.util import normalizeUUIDOrNot
 
@@ -817,9 +816,9 @@
             ],
             From=ch.join(co).join(cb).join(tr),
             Where=(
-                ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID     ).And(
-                tr.CALENDAR_OBJECT_RESOURCE_ID == co.RESOURCE_ID   ).And(
-                cb.CALENDAR_RESOURCE_ID == tr.CALENDAR_RESOURCE_ID ).And(
+                ch.RESOURCE_ID == cb.CALENDAR_HOME_RESOURCE_ID).And(
+                tr.CALENDAR_OBJECT_RESOURCE_ID == co.RESOURCE_ID).And(
+                cb.CALENDAR_RESOURCE_ID == tr.CALENDAR_RESOURCE_ID).And(
                 cb.BIND_MODE == _BIND_MODE_OWN
             ),
             GroupBy=(
@@ -932,7 +931,7 @@
         count = 0
         for dropboxID, path in results:
             attachment = Attachment(self, dropboxID, path)
-            (yield attachment.remove( ))
+            (yield attachment.remove())
             count += 1
         returnValue(count)
 
@@ -1387,6 +1386,7 @@
     def _loadPropertyStore(self):
         props = yield PropertyStore.load(
             self.uid(),
+            None,
             self._txn,
             self._resourceID,
             notifyCallback=self.notifyChanged
@@ -1908,18 +1908,21 @@
             # REVISIONS table still exists so we have to detect that and do db
             # INSERT or UPDATE as appropriate
 
-            found = bool( (
+            found = bool((
                 yield self._insertFindPreviouslyNamedQuery.on(
-                    self._txn, resourceID=self._resourceID, name=name)) )
+                    self._txn, resourceID=self._resourceID, name=name)))
             if found:
                 self._syncTokenRevision = (
                     yield self._updatePreviouslyNamedQuery.on(
                         self._txn, resourceID=self._resourceID, name=name)
                 )[0][0]
             else:
+                #FIXME: homeID=CommonHomeChild.ownerHome()._resourceID when it works
+                homeID = self.viewerHome()._resourceID if self.owned() else (yield self.sharerHomeID())
+
                 self._syncTokenRevision = (
                     yield self._completelyNewRevisionQuery.on(
-                        self._txn, homeID=self._home._resourceID,
+                        self._txn, homeID=homeID,
                         resourceID=self._resourceID, name=name)
                 )[0][0]
         self._maybeNotify()
@@ -1945,19 +1948,19 @@
 
     _objectResourceClass = None
 
-    _bindSchema              = None
-    _homeSchema              = None
-    _homeChildSchema         = None
+    _bindSchema = None
+    _homeSchema = None
+    _homeChildSchema = None
     _homeChildMetaDataSchema = None
-    _revisionsSchema         = None
-    _objectSchema            = None
+    _revisionsSchema = None
+    _objectSchema = None
 
-    _bindTable           = None
-    _homeChildTable      = None
-    _homeChildBindTable  = None
-    _revisionsTable      = None
-    _revisionsBindTable  = None
-    _objectTable         = None
+    _bindTable = None
+    _homeChildTable = None
+    _homeChildBindTable = None
+    _revisionsTable = None
+    _revisionsBindTable = None
+    _objectTable = None
 
 
     def __init__(self, home, name, resourceID, mode, status=None, message=None):
@@ -1969,19 +1972,19 @@
         else:
             notifiers = None
 
-        self._home              = home
-        self._name              = name
-        self._resourceID        = resourceID
-        self._bindMode          = mode
-        self._bindStatus        = status
-        self._bindMessage       = message
-        self._created           = None
-        self._modified          = None
-        self._objects           = {}
-        self._objectNames       = None
+        self._home = home
+        self._name = name
+        self._resourceID = resourceID
+        self._bindMode = mode
+        self._bindStatus = status
+        self._bindMessage = message
+        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
+        self._notifiers = notifiers
+        self._index = None  # Derived classes need to set this
 
 
     @classproperty
@@ -2065,7 +2068,7 @@
         child = cls._homeChildSchema
         childMetaData = cls._homeChildMetaDataSchema
 
-        columns = [bind.BIND_MODE, 
+        columns = [bind.BIND_MODE,
                    bind.HOME_RESOURCE_ID,
                    bind.RESOURCE_ID,
                    bind.RESOURCE_NAME,
@@ -2148,18 +2151,7 @@
                 mode=mode, status=status, message=message,
                 resourceID=self._resourceID, homeID=shareeHome._resourceID
             ))[0][0]
-        
-        ''' Only needed when setSharingUID is removed
-        if status == _BIND_STATUS_ACCEPTED:
-            shareeProps = yield PropertyStore.load(self._home.uid(), self._txn,
-                                                   self._resourceID)
-            dn = PropertyName.fromElement(DisplayName)
-            dnprop = (self.properties().get(dn) or
-                      DisplayName.fromString(self.name()))
-    
-            shareeProps[dn] = dnprop
-        '''
-        
+                
         # Must send notification to ensure cache invalidation occurs
         yield self.notifyChanged()
 
@@ -2206,7 +2198,8 @@
                             bind.RESOURCE_NAME:name}.iteritems() if v is not None])
                                 
         if len(columnMap):
-
+            
+            #TODO:  with bit of parameter wrangling, call shareWith() here instead.
             sharedname = yield self._updateBindColumnsQuery(columnMap).on(
                             self._txn,
                             resourceID=self._resourceID, homeID=shareeView._home._resourceID
@@ -2221,18 +2214,6 @@
                 #TODO: Is is OK to always call _initSyncToken ?
                 if shareeView._bindStatus == _BIND_STATUS_ACCEPTED:
                     yield shareeView._initSyncToken()
-            
-                    ''' Only needed when setSharingUID is removed
-
-                    shareeProps = yield PropertyStore.load(self._home.uid(), self._txn,
-                                                           self._resourceID)
-                    dn = PropertyName.fromElement(DisplayName)
-                    dnprop = (self.properties().get(dn) or
-                              DisplayName.fromString(self.name()))
-            
-                    shareeProps[dn] = dnprop
-                    '''
-
                 elif shareeView._bindStatus == _BIND_STATUS_DECLINED:
                     shareeView._deletedSyncToken(sharedRemoval=True);
 
@@ -2344,7 +2325,7 @@
     def _bindFor(cls, condition): #@NoSelf
         bind = cls._bindSchema
         return Select(
-            [bind.BIND_MODE, 
+            [bind.BIND_MODE,
              bind.HOME_RESOURCE_ID,
              bind.RESOURCE_ID,
              bind.RESOURCE_NAME,
@@ -2389,7 +2370,7 @@
                 home=(yield self._txn.homeWithResourceID(self._home._homeType,
                                                     homeResourceID)),
                 name=resourceName, resourceID=self._resourceID,
-                mode=bindMode, status=bindStatus, 
+                mode=bindMode, status=bindStatus,
                 message=bindMessage,
             )
             yield new.initFromStore()
@@ -2429,7 +2410,7 @@
                 home=(yield self._txn.homeWithResourceID(self._home._homeType,
                                                     homeResourceID)),
                 name=resourceName, resourceID=self._resourceID,
-                mode=bindMode, status=bindStatus, 
+                mode=bindMode, status=bindStatus,
                 message=bindMessage,
             )
             yield new.initFromStore()
@@ -2480,7 +2461,7 @@
             child = cls(
                 home=home,
                 name=resourceName, resourceID=resourceID,
-                mode=bindMode, status=bindStatus, 
+                mode=bindMode, status=bindStatus,
                 message=bindMessage,
             )
             for attr, value in zip(cls.metadataAttributes(), metadata):
@@ -2526,7 +2507,7 @@
         child = cls(
             home=home,
             name=resourceName, resourceID=resourceID,
-            mode=bindMode, status=bindStatus, 
+            mode=bindMode, status=bindStatus,
             message=bindMessage
         )
         yield child.initFromStore()
@@ -2589,7 +2570,7 @@
         child = cls(
             home=home,
             name=name, resourceID=resourceID,
-            mode=bindMode, status=bindStatus, 
+            mode=bindMode, status=bindStatus,
             message=bindMessage
         )
         yield child.initFromStore()
@@ -2628,7 +2609,7 @@
         child = cls(
             home=home,
             name=resourceName, resourceID=resourceID,
-            mode=bindMode, status=bindStatus, 
+            mode=bindMode, status=bindStatus,
             message=bindMessage,
         )
         yield child.initFromStore()
@@ -2853,9 +2834,9 @@
 
         # Set to non-existent state
         self._resourceID = None
-        self._created    = None
-        self._modified   = None
-        self._objects    = {}
+        self._created = None
+        self._modified = None
+        self._objects = {}
 
         yield self.notifyChanged()
 
@@ -2911,10 +2892,6 @@
             returnValue(rid)
 
 
-    def setSharingUID(self, uid):
-        self.properties()._setPerUserUID(uid)
-
-
     @inlineCallbacks
     def objectResources(self):
         """
@@ -3179,9 +3156,19 @@
 
     @inlineCallbacks
     def _loadPropertyStore(self, props=None):
+        if self.owned():
+            defaultUser = self.ownerHome().uid()
+        else:
+            #FIXME: use defaultUser=CommonHomeChild.ownerHome() when it works
+            sharerHomeID = yield self.sharerHomeID()
+            sharerHome = yield self._txn.homeWithResourceID(self.viewerHome()._homeType,
+                                                            sharerHomeID)
+            defaultUser = sharerHome.uid()
+            
         if props is None:
             props = yield PropertyStore.load(
-                self.ownerHome().uid(),
+                defaultUser,
+                self.viewerHome().uid(),
                 self._txn,
                 self._resourceID,
                 notifyCallback=self.notifyChanged
@@ -3366,7 +3353,7 @@
         if dataRows:
             # Get property stores for all these child resources (if any found)
             if parent.objectResourcesHaveProperties():
-                propertyStores =(yield PropertyStore.forMultipleResources(
+                propertyStores = (yield PropertyStore.forMultipleResources(
                     parent._home.uid(),
                     parent._txn,
                     cls._objectSchema.RESOURCE_ID,
@@ -3434,7 +3421,7 @@
         if dataRows:
             # Get property stores for all these child resources
             if parent.objectResourcesHaveProperties():
-                propertyStores =(yield PropertyStore.forMultipleResourcesWithResourceIDs(
+                propertyStores = (yield PropertyStore.forMultipleResourcesWithResourceIDs(
                     parent._home.uid(),
                     parent._txn,
                     tuple([row[0] for row in dataRows]),
@@ -3583,6 +3570,7 @@
             if self._parentCollection.objectResourcesHaveProperties():
                 props = yield PropertyStore.load(
                     self._parentCollection.ownerHome().uid(),
+                    None,
                     self._txn,
                     self._resourceID,
                     created=created
@@ -3847,6 +3835,7 @@
     def _loadPropertyStore(self):
         self._propertyStore = yield PropertyStore.load(
             self._uid,
+            None,
             self._txn,
             self._resourceID,
             notifyCallback=self.notifyChanged
@@ -3867,8 +3856,20 @@
 
     def uid(self):
         return self._uid
+    
 
+    def owned(self):
+        return True
 
+
+    def ownerHome(self):
+        return self._home
+    
+
+    def viewerHome(self):
+        return self._home
+
+
     @inlineCallbacks
     def notificationObjects(self):
         results = (yield NotificationObject.loadAllObjects(self))
@@ -4125,7 +4126,7 @@
 
         if dataRows:
             # Get property stores for all these child resources (if any found)
-            propertyStores =(yield PropertyStore.forMultipleResources(
+            propertyStores = (yield PropertyStore.forMultipleResources(
                 parent.uid(),
                 parent._txn,
                 schema.NOTIFICATION.RESOURCE_ID,

Modified: CalendarServer/branches/users/gaya/inviteclean/txdav/common/icommondatastore.py
===================================================================
--- CalendarServer/branches/users/gaya/inviteclean/txdav/common/icommondatastore.py	2012-08-16 01:37:11 UTC (rev 9712)
+++ CalendarServer/branches/users/gaya/inviteclean/txdav/common/icommondatastore.py	2012-08-16 19:46:22 UTC (rev 9713)
@@ -246,20 +246,3 @@
     A collection resource which may be shared.
     """
 
-    def setSharingUID(shareeUID):
-        """
-        This is a temporary shim method due to the way L{twistedcaldav.sharing}
-        works, which is that it expects to look in the 'sharesDB' object to
-        find what calendars are shared by whom, separately looks up the owner's
-        calendar home based on that information, then sets the sharee's UID on
-        that calendar, the main effect of which is to change the per-user uid
-        of the properties for that calendar object.
-
-        What I{should} be happening is that the calendars just show up in the
-        sharee's calendar home, and have a separate methods to determine the
-        sharee's and the owner's calendar homes, so the front end can tell it's
-        shared.
-
-        @param shareeUID: the UID of the sharee.
-        @type shareeUID: C{str}
-        """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120816/dae88ce2/attachment-0001.html>


More information about the calendarserver-changes mailing list