[CalendarServer-changes] [1207]
CalendarServer/branches/users/cdaboo/sqlprops-1202/lib-patches/
Twisted/twisted.web2.dav.element.parser.patch
source_changes at macosforge.org
source_changes at macosforge.org
Sat Feb 17 16:24:22 PST 2007
Revision: 1207
http://trac.macosforge.org/projects/calendarserver/changeset/1207
Author: cdaboo at apple.com
Date: 2007-02-17 16:24:22 -0800 (Sat, 17 Feb 2007)
Log Message:
-----------
Clean-up unknown element change.
Modified Paths:
--------------
CalendarServer/branches/users/cdaboo/sqlprops-1202/lib-patches/Twisted/twisted.web2.dav.element.parser.patch
Modified: CalendarServer/branches/users/cdaboo/sqlprops-1202/lib-patches/Twisted/twisted.web2.dav.element.parser.patch
===================================================================
--- CalendarServer/branches/users/cdaboo/sqlprops-1202/lib-patches/Twisted/twisted.web2.dav.element.parser.patch 2007-02-17 18:53:33 UTC (rev 1206)
+++ CalendarServer/branches/users/cdaboo/sqlprops-1202/lib-patches/Twisted/twisted.web2.dav.element.parser.patch 2007-02-18 00:24:22 UTC (rev 1207)
@@ -2,66 +2,26 @@
===================================================================
--- twisted/web2/dav/element/parser.py (revision 18545)
+++ twisted/web2/dav/element/parser.py (working copy)
-@@ -106,6 +106,26 @@
- "children" : [],
- }]
+@@ -123,15 +123,10 @@
+ for attr_name in attributes.getQNames():
+ attributes_dict[attr_name.encode("utf-8")] = attributes.getValueByQName(attr_name)
-+ # Keep a cache of the subclasses we create for unknown XML
-+ # elements, so that we don't create multiple classes for the
-+ # same element; it's fairly typical for elements to appear
-+ # multiple times in a document.
-+ self.unknownElementClasses = {}
-+
-+ # New-style classes keep weak references to all subclasses.
-+ # As a result, the subclasses we create continue to effect the
-+ # footprint of WebDAVUnknownElement even after they are
-+ # deallocated, up to the maximum number of subclasses that exist
-+ # simultaneously. The number of such weak references doesn't appear
-+ # to decrease. In order to avoid growing it unneccessarily, create a
-+ # subclass for use by this document, subclass the new class instead,
-+ # and then delete it when we're done, thereby adding only one weak
-+ # reference to WebDAVUnknownElement's list.
-+ # http://trac.macosforge.org/projects/calendarserver/ticket/101
-+ class UnknownElement (WebDAVUnknownElement):
-+ pass
-+ self.unknownElementClass = UnknownElement
-+
- def endDocument(self):
- top = self.stack[-1]
-
-@@ -115,6 +135,8 @@
- assert len(top["children"]) is 1, "Must have exactly one root element, got %d" % len(top["children"])
-
- self.dom = WebDAVDocument(top["children"][0])
-+ del(self.unknownElementClasses)
-+ del(self.unknownElementClass)
-
- def startElementNS(self, name, qname, attributes):
- attributes_dict = {}
-@@ -125,13 +147,16 @@
-
- tag_namespace, tag_name = name
-
+- tag_namespace, tag_name = name
+-
- if (name not in elements_by_tag_name):
- class UnknownElement (WebDAVUnknownElement):
- namespace = tag_namespace
- name = tag_name
- element_class = UnknownElement
+- else:
+ if name in elements_by_tag_name:
-+ element_class = elements_by_tag_name[name]
-+ elif name in self.unknownElementClasses:
-+ element_class = self.unknownElementClasses[name]
- else:
-- element_class = elements_by_tag_name[name]
-+ #class UnknownElement (self.unknownElementClass):
-+ # namespace = tag_namespace
-+ # name = tag_name
+ element_class = elements_by_tag_name[name]
++ else:
+ element_class = WebDAVUnknownElement
-+ #self.unknownElementClasses[name] = UnknownElement
self.stack.append({
"name" : name,
-@@ -151,6 +176,9 @@
+@@ -151,6 +146,9 @@
# children.
try:
element = top["class"](*top["children"], **top["attributes"])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070217/eda93f7d/attachment.html
More information about the calendarserver-changes
mailing list