[CalendarServer-changes] [9920] CalendarServer/branches/users/gaya/sharedgroups/txdav

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 10 10:51:28 PDT 2012


Revision: 9920
          http://trac.calendarserver.org//changeset/9920
Author:   gaya at apple.com
Date:     2012-10-10 10:51:28 -0700 (Wed, 10 Oct 2012)
Log Message:
-----------
merge in changeset/9919 from trunk

Modified Paths:
--------------
    CalendarServer/branches/users/gaya/sharedgroups/txdav/base/propertystore/base.py
    CalendarServer/branches/users/gaya/sharedgroups/txdav/common/datastore/sql.py

Modified: CalendarServer/branches/users/gaya/sharedgroups/txdav/base/propertystore/base.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups/txdav/base/propertystore/base.py	2012-10-10 16:00:34 UTC (rev 9919)
+++ CalendarServer/branches/users/gaya/sharedgroups/txdav/base/propertystore/base.py	2012-10-10 17:51:28 UTC (rev 9920)
@@ -26,7 +26,7 @@
 from twext.python.log import LoggingMixIn
 from txdav.xml import element as davxml
 from txdav.xml.base import encodeXMLName
-from twext.web2.dav.resource import TwistedGETContentMD5,\
+from twext.web2.dav.resource import TwistedGETContentMD5, \
     TwistedQuotaRootProperty
 
 from txdav.idav import IPropertyStore, IPropertyName
@@ -48,12 +48,14 @@
         if (index is -1 or not len(sname) > index or not sname[0] == "{"):
             raise TypeError("Invalid sname: %r" % (sname,))
 
-        return PropertyName(sname[1:index], sname[index+1:])
+        return PropertyName(sname[1:index], sname[index + 1:])
 
+
     @staticmethod
     def fromElement(element):
         return PropertyName(element.namespace, element.name)
 
+
     def __init__(self, namespace, name):
         self.namespace = namespace
         self.name = name
@@ -89,10 +91,12 @@
             self.toString(),
         )
 
+
     def toString(self):
         return encodeXMLName(self.namespace, self.name)
 
 
+
 class AbstractPropertyStore(LoggingMixIn, DictMixin):
     """
     Base property store.
@@ -121,7 +125,7 @@
         @param shareeUser: the per user uid or None if the same as defaultUser
         @type shareeUser: C{str}
         """
-        
+
         assert(defaultUser is not None or shareeUser is not None)
         self._defaultUser = shareeUser if defaultUser is None else defaultUser
         self._perUser = defaultUser if shareeUser is None else shareeUser
@@ -132,13 +136,20 @@
     def __str__(self):
         return "<%s>" % (self.__class__.__name__)
 
+
+    def _setDefaultUserUID(self, uid):
+        self._defaultUser = uid
+
+
     def _setPerUserUID(self, uid):
         self._perUser = uid
 
+
     def setSpecialProperties(self, shadowableKeys, globalKeys):
         self._shadowableKeys.update(shadowableKeys)
         self._globalKeys.update(globalKeys)
 
+
     #
     # Subclasses must override these
     #
@@ -146,30 +157,37 @@
     def _getitem_uid(self, key, uid):
         raise NotImplementedError()
 
+
     def _setitem_uid(self, key, value, uid):
         raise NotImplementedError()
 
+
     def _delitem_uid(self, key, uid):
         raise NotImplementedError()
 
+
     def _keys_uid(self, uid):
         raise NotImplementedError()
-    
+
+
     def _removeResource(self):
         raise NotImplementedError()
 
+
     def flush(self):
         raise NotImplementedError()
 
+
     def abort(self):
         raise NotImplementedError()
 
+
     #
     # Required UserDict implementations
     #
 
     def __getitem__(self, key):
-        # Handle per-user behavior 
+        # Handle per-user behavior
         if self.isShadowableProperty(key):
             try:
                 result = self._getitem_uid(key, self._perUser)
@@ -181,22 +199,25 @@
         else:
             return self._getitem_uid(key, self._perUser)
 
+
     def __setitem__(self, key, value):
-        # Handle per-user behavior 
+        # Handle per-user behavior
         if self.isGlobalProperty(key):
             return self._setitem_uid(key, value, self._defaultUser)
         else:
             return self._setitem_uid(key, value, self._perUser)
 
+
     def __delitem__(self, key):
-        # Handle per-user behavior 
+        # Handle per-user behavior
         if self.isGlobalProperty(key):
             self._delitem_uid(key, self._defaultUser)
         else:
             self._delitem_uid(key, self._perUser)
 
+
     def keys(self):
-        
+
         userkeys = list(self._keys_uid(self._perUser))
         if self._defaultUser != self._perUser:
             defaultkeys = self._keys_uid(self._defaultUser)
@@ -205,6 +226,7 @@
                     userkeys.append(key)
         return tuple(userkeys)
 
+
     def update(self, other):
         # FIXME: direct tests.
         # FIXME: support positional signature (although since strings aren't
@@ -212,20 +234,25 @@
         for key in other:
             self[key] = other[key]
 
+
     # Per-user property handling
     def isShadowableProperty(self, key):
         return key in self._shadowableKeys
-    
+
+
     def isGlobalProperty(self, key):
         return key in self._globalKeys
 
+
     def copyAllProperties(self, other):
         """
         Copy all the properties from another store into this one. This needs to be done
         independently of the UID. Each underlying store will need to implement this.
         """
         pass
-        
+
+
+
 # FIXME: Actually, we should replace this with calls to IPropertyName()
 def validKey(key):
     # Used by implementations to verify that keys are valid

Modified: CalendarServer/branches/users/gaya/sharedgroups/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/branches/users/gaya/sharedgroups/txdav/common/datastore/sql.py	2012-10-10 16:00:34 UTC (rev 9919)
+++ CalendarServer/branches/users/gaya/sharedgroups/txdav/common/datastore/sql.py	2012-10-10 17:51:28 UTC (rev 9920)
@@ -2538,7 +2538,7 @@
         # Create the actual objects merging in properties
         for items in dataRows:
             bindMode, homeID, resourceID, resourceName, bindStatus, bindMessage = items[:6] #@UnusedVariable
-            metadata = items[7:]
+            metadata = items[6:]
 
             if bindStatus == _BIND_MODE_OWN:
                 ownerHome = home
@@ -2558,6 +2558,11 @@
                 setattr(child, attr, value)
             child._syncTokenRevision = revisions[resourceID]
             propstore = propertyStores.get(resourceID, None)
+
+            # We have to re-adjust the property store object to account for possible shared
+            # collections as previously we loaded them all as if they were owned
+            if bindStatus != _BIND_MODE_OWN:
+                propstore._setDefaultUserUID(ownerHome.uid())
             yield child._loadPropertyStore(propstore)
             results.append(child)
         returnValue(results)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121010/fa90e096/attachment.html>


More information about the calendarserver-changes mailing list