[CalendarServer-changes] [2513] CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops .patch

source_changes at macosforge.org source_changes at macosforge.org
Thu May 29 16:05:57 PDT 2008


Revision: 2513
          http://trac.macosforge.org/projects/calendarserver/changeset/2513
Author:   wsanchez at apple.com
Date:     2008-05-29 16:05:56 -0700 (Thu, 29 May 2008)

Log Message:
-----------
Go back to using compressed XML for properties.

Modified Paths:
--------------
    CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch

Modified: CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch
===================================================================
--- CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch	2008-05-29 22:33:54 UTC (rev 2512)
+++ CalendarServer/trunk/lib-patches/Twisted/twisted.web2.dav.xattrprops.patch	2008-05-29 23:05:56 UTC (rev 2513)
@@ -11,7 +11,7 @@
 +from random import random
 +from errno import EAGAIN
 +from zlib import compress, decompress
-+from cPickle import dumps as pickle, loads as unpickle, PicklingError, UnpicklingError
++from cPickle import loads as unpickle, PicklingError, UnpicklingError
  
  import xattr
  
@@ -41,7 +41,7 @@
          return r
  
      def _decode(clazz, name):
-@@ -97,20 +96,81 @@
+@@ -97,19 +96,74 @@
  
      def get(self, qname):
          try:
@@ -61,6 +61,7 @@
 +        #  1- Started with XML
 +        #  2- Started compressing the XML due to limits on xattr size
 +        #  3- Switched to pickle which is faster, still compressing
++        #  4- Back to compressed XML for interoperability, size
 +        #
 +        # We only write the current format, but we also read the old
 +        # ones for compatibility.
@@ -74,14 +75,14 @@
 +            legacy = True
  
 +        try:
-+            result = unpickle(data)
-+        except UnpicklingError:
++            doc = davxml.WebDAVDocument.fromString(data)
++            result = doc.root_element
++        except ValueError:
 +            legacy = True
 +
 +            try:
-+                doc = davxml.WebDAVDocument.fromString(data)
-+                result = doc.root_element
-+            except ValueError:
++                result = unpickle(data)
++            except UnpicklingError:
 +                msg = ("Invalid property value stored on server: {%s}%s %s"
 +                       % (qname[0], qname[1], data))
 +                log.err(msg)
@@ -107,14 +108,8 @@
      def set(self, property):
 -        self.attrs[self._encode(property.qname())] = property.toxml()
 +        for n in range(20):
++            data = compress(property.toxml())
 +            try:
-+                data = compress(pickle(property))
-+            except PicklingError, e:
-+                log.err("Unable to pickle property %r: %s" % (property, e))
- 
-+                # Can't pickle this for some reason; fall back to XML serialization
-+                data = compress(property.toxml())
-+            try:
 +                self.attrs[self._encode(property.qname())] = data
 +            except IOError, error:
 +                if error.errno != EAGAIN:
@@ -122,8 +117,6 @@
 +                sleep(random() / 10) # OMG Brutal Hax
 +            else:
 +                break
-+    
-+
+ 
          # Update the resource because we've modified it
          self.resource.fp.restat()
- 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080529/6a8909e0/attachment.htm 


More information about the calendarserver-changes mailing list