[CalendarServer-changes] [5871] CalendarServer/branches/new-store

source_changes at macosforge.org source_changes at macosforge.org
Mon Jul 12 08:52:36 PDT 2010


Revision: 5871
          http://trac.macosforge.org/projects/calendarserver/changeset/5871
Author:   glyph at apple.com
Date:     2010-07-12 08:52:35 -0700 (Mon, 12 Jul 2010)
Log Message:
-----------
Dynamically compute the path to set xattrs on, rather than updating it during commit.

Modified Paths:
--------------
    CalendarServer/branches/new-store/txcaldav/calendarstore/file.py
    CalendarServer/branches/new-store/txdav/common/datastore/file.py
    CalendarServer/branches/new-store/txdav/propertystore/xattr.py

Modified: CalendarServer/branches/new-store/txcaldav/calendarstore/file.py
===================================================================
--- CalendarServer/branches/new-store/txcaldav/calendarstore/file.py	2010-07-12 15:49:33 UTC (rev 5870)
+++ CalendarServer/branches/new-store/txcaldav/calendarstore/file.py	2010-07-12 15:52:35 UTC (rev 5871)
@@ -448,7 +448,7 @@
         return PropertyStore(
             self._calendarObject._parentCollection._home.peruser_uid(),
             self._calendarObject._parentCollection._home.uid(),
-            self._computePath()
+            self._computePath
         )
 
 

Modified: CalendarServer/branches/new-store/txdav/common/datastore/file.py
===================================================================
--- CalendarServer/branches/new-store/txdav/common/datastore/file.py	2010-07-12 15:49:33 UTC (rev 5870)
+++ CalendarServer/branches/new-store/txdav/common/datastore/file.py	2010-07-12 15:52:35 UTC (rev 5871)
@@ -234,7 +234,6 @@
                 temporary.moveTo(notificationPath)
                 c._name = name
                 # FIXME: _lots_ of duplication of work here.
-                props.path = notificationPath
                 props.flush()
             except (IOError, OSError), e:
                 if e.errno == EEXIST and notificationPath.isdir():
@@ -345,7 +344,6 @@
                 temporary.moveTo(childPath)
                 c._name = name
                 # FIXME: _lots_ of duplication of work here.
-                props.path = childPath
                 props.flush()
             except (IOError, OSError), e:
                 if e.errno == EEXIST and childPath.isdir():
@@ -411,7 +409,8 @@
         # FIXME: needs tests for actual functionality
         # FIXME: needs to be cached
         # FIXME: transaction tests
-        props = PropertyStore(self.peruser_uid(), self.uid(), self._path)
+        props = PropertyStore(self.peruser_uid(), self.uid(),
+                              lambda : self._path)
         self._transaction.addOperation(props.flush, "flush home properties")
         return props
 
@@ -625,7 +624,7 @@
         props = PropertyStore(
             self._peruser_uid,
             self._home.uid(),
-            self._path
+            lambda: self._path
         )
         self.initPropertyStore(props)
 
@@ -688,7 +687,7 @@
         props = PropertyStore(
             self._parentCollection._home.peruser_uid(),
             self._parentCollection._home.uid(),
-            self._path
+            lambda : self._path
         )
         self._transaction.addOperation(props.flush, "object properties flush")
         return props

Modified: CalendarServer/branches/new-store/txdav/propertystore/xattr.py
===================================================================
--- CalendarServer/branches/new-store/txdav/propertystore/xattr.py	2010-07-12 15:49:33 UTC (rev 5870)
+++ CalendarServer/branches/new-store/txdav/propertystore/xattr.py	2010-07-12 15:52:35 UTC (rev 5871)
@@ -1,3 +1,4 @@
+# -*- test-case-name: txcaldav.calendarstore,txcarddav.addressbookstore -*-
 ##
 # Copyright (c) 2010 Apple Inc. All rights reserved.
 #
@@ -81,24 +82,27 @@
         "http://twistedmatrix.com/xml_namespace/dav/"         :"TD:",
         "http://twistedmatrix.com/xml_namespace/dav/private/" :"TDP:",
     }
-    _namespaceExpand = dict([ (v, k) for k, v in _namespaceCompress.iteritems( ) ])
+    _namespaceExpand = dict([ (v, k) for k, v in _namespaceCompress.iteritems() ])
 
-    def __init__(self, peruser, defaultuser, path):
+    def __init__(self, peruser, defaultuser, pathFactory):
         """
         Initialize a L{PropertyStore}.
 
-        @param path: the path to set extended attributes on.
-        @type path: L{CachingFilePath}
+        @param pathFactory: a 0-arg callable that returns the L{CachingFilePath} to set extended attributes on.
         """
         super(PropertyStore, self).__init__(peruser, defaultuser)
 
-        self.path = path
+        self._pathFactory = pathFactory
         # self.attrs = xattr(path.path)
         self.removed = set()
         self.modified = {}
-        
-        
+
+
     @property
+    def path(self):
+        return self._pathFactory()
+
+    @property
     def attrs(self):
         return xattr(self.path.path)
 
@@ -106,7 +110,7 @@
         return "<%s %s>" % (self.__class__.__name__, self.path.path)
 
     def _encodeKey(self, effective, compressNamespace=True):
-        
+
         qname, uid = effective
         namespace = self._namespaceCompress.get(qname.namespace, qname.namespace) if compressNamespace else qname.namespace
         result = urllib.quote("{%s}%s" % (namespace, qname.name), safe="{}:")
@@ -122,15 +126,15 @@
         index1 = name.find("{")
         index2 = name.find("}")
 
-        if (index1 is -1 or index2 is -1 or not len(name) > index2):
+        if (index1 is - 1 or index2 is - 1 or not len(name) > index2):
             raise ValueError("Invalid encoded name: %r" % (name,))
         if index1 == 0:
             uid = None
         else:
             uid = name[:index1]
-        propnamespace = name[index1+1:index2]
+        propnamespace = name[index1 + 1:index2]
         propnamespace = self._namespaceExpand.get(propnamespace, propnamespace)
-        propname = name[index2+1:]
+        propname = name[index2 + 1:]
 
         return PropertyName(propnamespace, propname), uid
 
@@ -163,7 +167,7 @@
                 except IOError, e:
                     raise KeyError(key)
 
-                try:                    
+                try:
                     # Write it back using the compressed format
                     self.attrs[self._encodeKey(effectiveKey)] = data
                     del self.attrs[self._encodeKey(effectiveKey, compressNamespace=False)]
@@ -253,7 +257,7 @@
         for effectivekey in self.modified:
             if effectivekey[1] == uid and effectivekey not in seen:
                 yield effectivekey[0]
-            
+
     #
     # I/O
     #
@@ -269,8 +273,8 @@
         if not self.path.exists():
             return
 
-        attrs    = self.attrs
-        removed  = self.removed
+        attrs = self.attrs
+        removed = self.removed
         modified = self.modified
 
         for key in removed:
@@ -287,9 +291,9 @@
             assert key not in removed
             value = modified[key]
             attrs[self._encodeKey(key)] = compress(value.toxml())
-        
+
         self.removed.clear()
-        self.modified.clear()        
+        self.modified.clear()
 
     def abort(self):
         self.removed.clear()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100712/b71558ae/attachment.html>


More information about the calendarserver-changes mailing list