[CalendarServer-changes] [3896] CalendarServer/branches/exarkun/update-twisted-3816

source_changes at macosforge.org source_changes at macosforge.org
Thu Mar 19 13:28:07 PDT 2009


Revision: 3896
          http://trac.macosforge.org/projects/calendarserver/changeset/3896
Author:   exarkun at twistedmatrix.com
Date:     2009-03-19 13:28:06 -0700 (Thu, 19 Mar 2009)
Log Message:
-----------
migrated to twisted

Modified Paths:
--------------
    CalendarServer/branches/exarkun/update-twisted-3816/run

Removed Paths:
-------------
    CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.dav.element.base.patch
    CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.log.patch
    CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.server.patch
    CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.static.patch
    CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.test.test_http.patch

Deleted: CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.dav.element.base.patch
===================================================================
--- CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.dav.element.base.patch	2009-03-19 19:54:43 UTC (rev 3895)
+++ CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.dav.element.base.patch	2009-03-19 20:28:06 UTC (rev 3896)
@@ -1,267 +0,0 @@
-Index: twisted/web2/dav/element/base.py
-===================================================================
---- twisted/web2/dav/element/base.py	(revision 26343)
-+++ twisted/web2/dav/element/base.py	(working copy)
-@@ -46,7 +46,7 @@
- ]
- 
- import string
--import StringIO
-+import cStringIO as StringIO
- import xml.dom.minidom
- 
- import datetime
-@@ -91,6 +91,35 @@
-             raise NotImplementedError("WebDAVElement subclass %s is not implemented."
-                                       % (self.__class__.__name__,))
- 
-+        my_children = []
-+
-+        allowPCDATA = self.allowed_children.has_key(PCDATAElement)
-+
-+        for child in children:
-+            if child is None:
-+                continue
-+
-+            if isinstance(child, (str, unicode)):
-+                child = PCDATAElement(child)
-+
-+            if isinstance(child, PCDATAElement) and not allowPCDATA:
-+                continue
-+
-+            my_children.append(child)
-+
-+        self.children = tuple(my_children)
-+
-+        self.attributes = attributes
-+
-+    def validate(self):
-+
-+        children = self.children
-+        attributes = self.attributes
-+
-+        if self.allowed_children is None:
-+            raise NotImplementedError("WebDAVElement subclass %s is not implemented."
-+                                      % (self.__class__.__name__,))
-+
-         #
-         # Validate that children are of acceptable types
-         #
-@@ -103,13 +132,10 @@
-         my_children = []
- 
-         for child in children:
--            if child is None:
--                continue
- 
--            if isinstance(child, (str, unicode)):
--                child = PCDATAElement(child)
--
-             assert isinstance(child, (WebDAVElement, PCDATAElement)), "Not an element: %r" % (child,)
-+            
-+            child.validate()
- 
-             for allowed, (min, max) in allowed_children.items():
-                 if type(allowed) == type and isinstance(child, allowed):
-@@ -146,24 +172,26 @@
- 
-         if self.allowed_attributes:
-             for name in attributes:
--                if name in self.allowed_attributes:
--                    my_attributes[name] = attributes[name]
--                else:
--                    log.msg("Attribute %s is unexpected and therefore ignored in %s element"
--                            % (name, self.sname()))
-+                if name not in self.allowed_attributes:
-+                    log.msg("Attribute %s is unexpected in %s element" % (name, self.sname()))
-+                my_attributes[name] = attributes[name]
- 
-             for name, required in self.allowed_attributes.items():
-                 if required and name not in my_attributes:
-                     raise ValueError("Attribute %s is required in %s element"
-                                      % (name, self.sname()))
- 
--        elif not isinstance(self, WebDAVUnknownElement):
--            if attributes:
--                log.msg("Attributes %s are unexpected and therefore ignored in %s element"
-+        else:
-+            if not isinstance(self, WebDAVUnknownElement) and attributes:
-+                log.msg("Attributes %s are unexpected in %s element"
-                         % (attributes.keys(), self.sname()))
-+            my_attributes.update(attributes)
- 
-         self.attributes = my_attributes
- 
-+    def emptyCopy(self):
-+        return self.__class__()
-+
-     def __str__(self):
-         return self.sname()
- 
-@@ -191,14 +219,93 @@
-         return child in self.children
- 
-     def writeXML(self, output):
--        document = xml.dom.minidom.Document()
--        self.addToDOM(document, None)
--        PrintXML(document, stream=output)
-+        # FIXME: Now have a 'fast' write implementation as well as previous PyXML-based one.
-+        # For now the fast one is the default and we will test to see if its good enough.
-+        
-+        usePyXML = False
-+        if usePyXML:
-+            document = xml.dom.minidom.Document()
-+            self.addToDOM(document, None)
-+            PrintXML(document, stream=output)
-+        else:
-+            output.write("<?xml version='1.0' encoding='UTF-8'?>\r\n")
-+            self.writeToStream(output, "", 0, True)
-+            output.write("\r\n")
-+    
-+    def writeToStream(self, output, ns, level, pretty):
-+        """
-+        Fast XML output.
- 
-+        @param output: C{stream} to write to.
-+        @param ns: C{str} containing the namespace of the enclosing element.
-+        @param level: C{int} containing the element nesting level (starts at 0).
-+        @param pretty: C{bool} whether to use 'pretty' formatted output or not.
-+        """
-+        
-+        # Do pretty indent
-+        if pretty and level:
-+            output.write("  " * level)
-+        
-+        # Check for empty element (one with either no children or a single PCDATA that is itself empty)
-+        if (len(self.children) == 0 or
-+            (len(self.children) == 1 and isinstance(self.children[0], PCDATAElement) and len(str(self.children[0])) == 0)):
-+
-+            # Write out any attributes or the namespace if difference from enclosing element.
-+            if self.attributes or (ns != self.namespace):
-+                output.write("<%s" % (self.name,))
-+                for name, value in self.attributes.iteritems():
-+                    self.writeAttributeToStream(output, name, value)
-+                if ns != self.namespace:
-+                    output.write(" xmlns='%s'" % (self.namespace,))
-+                output.write("/>")
-+            else:
-+                output.write("<%s/>" % (self.name,))
-+        else:
-+            # Write out any attributes or the namespace if difference from enclosing element.
-+            if self.attributes or (ns != self.namespace):
-+                output.write("<%s" % (self.name,))
-+                for name, value in self.attributes.iteritems():
-+                    self.writeAttributeToStream(output, name, value)
-+                if ns != self.namespace:
-+                    output.write(" xmlns='%s'" % (self.namespace,))
-+                    ns = self.namespace
-+                output.write(">")
-+            else:
-+                output.write("<%s>" % (self.name,))
-+                
-+            # Determine nature of children when doing pretty print: we do
-+            # not want to insert CRLFs or any other whitespace in PCDATA.
-+            hasPCDATA = False
-+            for child in self.children:
-+                if isinstance(child, PCDATAElement):
-+                    hasPCDATA = True
-+                    break
-+            
-+            # Write out the children.
-+            if pretty and not hasPCDATA:
-+                output.write("\r\n")
-+            for child in self.children:
-+                child.writeToStream(output, ns, level+1, pretty)
-+                
-+            # Close the element.
-+            if pretty and not hasPCDATA and level:
-+                output.write("  " * level)
-+            output.write("</%s>" % (self.name,))
-+
-+        if pretty and level:
-+            output.write("\r\n")
-+
-+    def writeAttributeToStream(self, output, name, value):
-+        
-+        # Quote any single quotes. We do not need to be any smarter than this.
-+        value = value.replace("'", "&apos;")
-+
-+        output.write(" %s='%s'" % (name, value,))  
-+      
-     def toxml(self):
-         output = StringIO.StringIO()
-         self.writeXML(output)
--        return output.getvalue()
-+        return str(output.getvalue())
- 
-     def element(self, document):
-         element = document.createElementNS(self.namespace, self.name)
-@@ -286,6 +393,9 @@
- 
-         self.data = data
- 
-+    def validate(self):
-+        pass
-+
-     def __str__(self):
-         return str(self.data)
- 
-@@ -325,6 +435,22 @@
-             log.err("Invalid PCDATA: %r" % (self.data,))
-             raise
- 
-+    def writeToStream(self, output, ns, level, pretty):
-+        # Do escaping/CDATA behavior
-+        if "\r" in self.data or "\n" in self.data:
-+            # Do CDATA
-+            cdata = "<![CDATA[%s]]>" % (self.data.replace("]]>", "]]&gt;"),)
-+        else:
-+            cdata = self.data
-+            if "&" in cdata:
-+                cdata = cdata.replace("&", "&amp;")
-+            if "<" in cdata:
-+                cdata = cdata.replace("<", "&lt;")
-+            if ">" in cdata:
-+                cdata = cdata.replace(">", "&gt;")
-+
-+        output.write(cdata)
-+
- class WebDAVOneShotElement (WebDAVElement):
-     """
-     Element with exactly one WebDAVEmptyElement child and no attributes.
-@@ -365,6 +491,18 @@
-         PCDATAElement: (0, None),
-     }
- 
-+    def qname(self):
-+        return (self.namespace, self.name)
-+
-+    def sname(self):
-+        return "{%s}%s" % (self.namespace, self.name)
-+
-+    def emptyCopy(self):
-+        copied = self.__class__()
-+        copied.name = self.name
-+        copied.namespace = self.namespace
-+        return copied
-+
- class WebDAVEmptyElement (WebDAVElement):
-     """
-     WebDAV element with no contents.
-@@ -400,6 +538,7 @@
-     """
-     WebDAV element containing PCDATA.
-     """
-+    @classmethod
-     def fromString(clazz, string):
-         if string is None:
-             return clazz()
-@@ -408,8 +547,6 @@
-         else:
-             return clazz(PCDATAElement(str(string)))
- 
--    fromString = classmethod(fromString)
--
-     allowed_children = { PCDATAElement: (0, None) }
- 
-     def __str__(self):

Deleted: CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.log.patch
===================================================================
--- CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.log.patch	2009-03-19 19:54:43 UTC (rev 3895)
+++ CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.log.patch	2009-03-19 20:28:06 UTC (rev 3896)
@@ -1,13 +0,0 @@
-Index: twisted/web2/log.py
-===================================================================
---- twisted/web2/log.py	(revision 19773)
-+++ twisted/web2/log.py	(working copy)
-@@ -88,7 +88,7 @@
- class LogWrapperResource(resource.WrapperResource):
-     def hook(self, request):
-         # Insert logger
--        request.addResponseFilter(logFilter, atEnd=True)
-+        request.addResponseFilter(logFilter, atEnd=True, onlyOnce=True)
- 
- monthname = [None, 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
-              'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']

Deleted: CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.server.patch
===================================================================
--- CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.server.patch	2009-03-19 19:54:43 UTC (rev 3895)
+++ CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.server.patch	2009-03-19 20:28:06 UTC (rev 3896)
@@ -1,129 +0,0 @@
-Index: twisted/web2/server.py
-===================================================================
---- twisted/web2/server.py	(revision 26342)
-+++ twisted/web2/server.py	(working copy)
-@@ -24,6 +24,7 @@
- from twisted.web2 import http_headers
- from twisted.web2.filter.range import rangefilter
- from twisted.web2 import error
-+from twisted.web2.dav.util import joinURL
- 
- from twisted.web2 import version as web2_version
- from twisted import __version__ as twisted_version
-@@ -171,6 +172,9 @@
-                        error.defaultErrorHandler, defaultHeadersFilter]
- 
-     def __init__(self, *args, **kw):
-+        
-+        self.initTime = time.time()
-+
-         if kw.has_key('site'):
-             self.site = kw['site']
-             del kw['site']
-@@ -178,17 +182,36 @@
-             self._initialprepath = kw['prepathuri']
-             del kw['prepathuri']
- 
-+        self._resourcesByURL = {}
-+        self._urlsByResource = {}
-+
-         # Copy response filters from the class
-         self.responseFilters = self.responseFilters[:]
-         self.files = {}
-         self.resources = []
-         http.Request.__init__(self, *args, **kw)
-+        try:
-+            self.serverInstance = self.chanRequest.channel.transport.server.port
-+        except AttributeError:
-+            self.serverInstance = "Unknown"
- 
--    def addResponseFilter(self, f, atEnd=False):
-+    def addResponseFilter(self, filter, atEnd=False, onlyOnce=False):
-+        """
-+        Add a response filter to this request.
-+        Response filters are applied to the response to this request in order.
-+        @param filter: a callable which takes an response argument and returns
-+            a response object.
-+        @param atEnd: if C{True}, C{filter} is added at the end of the list of
-+            response filters; if C{False}, it is added to the beginning.
-+        @param onlyOnce: if C{True}, C{filter} is not added to the list of
-+            response filters if it already in the list.
-+        """
-+        if onlyOnce and filter in self.responseFilters:
-+            return
-         if atEnd:
--            self.responseFilters.append(f)
-+            self.responseFilters.append(filter)
-         else:
--            self.responseFilters.insert(0, f)
-+            self.responseFilters.insert(0, filter)
- 
-     def unparseURL(self, scheme=None, host=None, port=None,
-                    path=None, params=None, querystring=None, fragment=None):
-@@ -293,6 +316,7 @@
- 
-         d = defer.Deferred()
-         d.addCallback(self._getChild, self.site.resource, self.postpath)
-+        d.addCallback(self._rememberResource, "/" + "/".join(quote(s) for s in self.postpath))
-         d.addCallback(lambda res, req: res.renderHTTP(req), self)
-         d.addCallback(self._cbFinishRender)
-         d.addErrback(self._processingFailed)
-@@ -349,7 +373,6 @@
-         if newpath is StopTraversal:
-             # We need to rethink how to do this.
-             #if newres is res:
--                self._rememberResource(res, url)
-                 return res
-             #else:
-             #    raise ValueError("locateChild must not return StopTraversal with a resource other than self.")
-@@ -365,7 +388,6 @@
-                 self.prepath.append(self.postpath.pop(0))
- 
-         child = self._getChild(None, newres, newpath, updatepaths=updatepaths)
--        self._rememberResource(child, url)
- 
-         return child
- 
-@@ -375,6 +397,7 @@
-         """
-         Remember the URL of a visited resource.
-         """
-+        self._resourcesByURL[url] = resource
-         self._urlsByResource[resource] = url
-         return resource
- 
-@@ -414,7 +437,8 @@
-             The contained response will have a status code of
-             L{responsecode.BAD_REQUEST}.
-         """
--        if url is None: return None
-+        if url is None:
-+            return defer.succeed(None)
- 
-         #
-         # Parse the URL
-@@ -435,9 +459,13 @@
-                 "URL is not on this site (%s://%s/): %s" % (scheme, self.headers.getHeader("host"), url)
-             ))
- 
--        segments = path.split("/")
-+        # Look for cached value
-+        cached = self._resourcesByURL.get(path, None)
-+        if cached is not None:
-+            return defer.succeed(cached)
-+
-+        segments = unquote(path).split("/")
-         assert segments[0] == "", "URL path didn't begin with '/': %s" % (path,)
--        segments = map(unquote, segments[1:])
- 
-         def notFound(f):
-             f.trap(http.HTTPError)
-@@ -445,7 +473,7 @@
-                 return f
-             return None
- 
--        d = defer.maybeDeferred(self._getChild, None, self.site.resource, segments, updatepaths=False)
-+        d = defer.maybeDeferred(self._getChild, None, self.site.resource, segments[1:], updatepaths=False)
-         d.addCallback(self._rememberResource, path)
-         d.addErrback(notFound)
-         return d

Deleted: CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.static.patch
===================================================================
--- CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.static.patch	2009-03-19 19:54:43 UTC (rev 3895)
+++ CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.static.patch	2009-03-19 20:28:06 UTC (rev 3896)
@@ -1,25 +0,0 @@
-Index: twisted/web2/static.py
-===================================================================
---- twisted/web2/static.py	(revision 26342)
-+++ twisted/web2/static.py	(working copy)
-@@ -197,7 +197,10 @@
-         super(File, self).__init__()
- 
-         self.putChildren = {}
--        self.fp = filepath.FilePath(path)
-+        if isinstance(path, filepath.FilePath):
-+            self.fp = path
-+        else:
-+            self.fp = filepath.FilePath(path)
-         # Remove the dots from the path to split
-         self.defaultType = defaultType
-         self.ignoredExts = list(ignoredExts)
-@@ -377,7 +380,7 @@
-             return responsecode.NOT_FOUND
- 
-         if self.fp.isdir():
--            if req.uri[-1] != "/":
-+            if req.path[-1] != "/":
-                 # Redirect to include trailing '/' in URI
-                 return http.RedirectResponse(req.unparseURL(path=req.path+'/'))
-             else:

Deleted: CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.test.test_http.patch
===================================================================
--- CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.test.test_http.patch	2009-03-19 19:54:43 UTC (rev 3895)
+++ CalendarServer/branches/exarkun/update-twisted-3816/lib-patches/Twisted/twisted.web2.test.test_http.patch	2009-03-19 20:28:06 UTC (rev 3896)
@@ -1,23 +0,0 @@
-Index: twisted/web2/test/test_http.py
-===================================================================
---- twisted/web2/test/test_http.py	(revision 26342)
-+++ twisted/web2/test/test_http.py	(working copy)
-@@ -321,6 +321,9 @@
-     def connectionLost(self, reason):
-         self.cmds.append(('connectionLost', reason))
- 
-+    def _finished(self, x):
-+        self._reallyFinished(x)
-+
- class TestResponse(object):
-     implements(iweb.IResponse)
- 
-@@ -1014,6 +1017,8 @@
-         response = TestResponse()
-         if self.uri == "/error":
-             response.code=402
-+        elif self.uri == "/forbidden":
-+            response.code=403
-         else:
-             response.code=404
-             response.write("URI %s unrecognized." % self.uri)

Modified: CalendarServer/branches/exarkun/update-twisted-3816/run
===================================================================
--- CalendarServer/branches/exarkun/update-twisted-3816/run	2009-03-19 19:54:43 UTC (rev 3895)
+++ CalendarServer/branches/exarkun/update-twisted-3816/run	2009-03-19 20:28:06 UTC (rev 3896)
@@ -636,7 +636,7 @@
     ;;
 esac;
 svn_uri="${proto}://svn.twistedmatrix.com/svn/Twisted/branches/dav-take-two-3081-3";
-svn_get "Twisted" "${twisted}" "${svn_uri}" 26434;
+svn_get "Twisted" "${twisted}" "${svn_uri}" 26444;
 
 # No py_build step, since we tend to do edit Twisted, we want the sources in
 # PYTHONPATH, not a build directory.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090319/f8e3a401/attachment-0001.html>


More information about the calendarserver-changes mailing list