CVS: Products/ParsedXML - ManageableDOM.py:1.109

Martijn Faassen <[email protected]> Mon, 16 Dec 2002 15:06:51 -0500
Newsgroups gmane.comp.web.zope.parsed-xml
Message-ID <[email protected]>
Update of /cvs-repository/Products/ParsedXML
In directory cvs.zope.org:/tmp/cvs-serv31387

Modified Files:
	ManageableDOM.py 
Log Message:
Fixed a severe memory leak that was triggered if a python script did
'doc.documentElement' where doc is a ParsedXML document. I'm not sure
why exactly this fixes the leak, but the tests pass as well as they
did before and this should even be less grotty and more efficient to boot.


=== Products/ParsedXML/ManageableDOM.py 1.108 => 1.109 ===
--- Products/ParsedXML/ManageableDOM.py:1.108	Sun May 19 11:51:11 2002
+++ Products/ParsedXML/ManageableDOM.py	Mon Dec 16 15:06:50 2002
@@ -89,6 +89,7 @@
 
 import Globals
 import Acquisition
+from Acquisition import aq_parent
 import App.Management
 from OFS.Traversable import Traversable
 from DateTime import DateTime # for manage_edit cookie expire
@@ -548,11 +549,11 @@
     def wrapNamedNodeMap(self, obj):
         if obj is None:
             return None
-        parent = self.getPersistentDoc() or self
+        parent = aq_parent(self) or self
         return ManageableNamedNodeMap(obj, self._persistentDoc).__of__(parent)
 
     def wrapNodeList(self, obj):
-        parent = self.getPersistentDoc() or self
+        parent = aq_parent(self) or self
         return ManageableNodeList(obj, self._persistentDoc).__of__(parent)
     
     def wrapDOMObj(self, node):
@@ -560,7 +561,7 @@
         if node is None:
             return
         wrapper_type = WRAPPER_TYPES[node._get_nodeType()]
-        parent = self.getPersistentDoc() or self
+        parent = aq_parent(self) or self
         return wrapper_type(node, self._persistentDoc).__of__(parent)
         
 # According to DOM Erratum Core-14, the empty string should be
@@ -609,7 +610,7 @@
             mdocType = None
         DOMDocument = self._createDOMDocument(namespaceURI, qualifiedName,
                                               mdocType)
-        return ManageableDocument(DOMDocument)
+        return ManageableDocument(DOMDocument, DOMDocument)
 
 theDOMImplementation = ManageableDOMImplementation()
 
@@ -620,7 +621,7 @@
     "A wrapper around a DOM Node."
 
     # this is mainly here to make later inheritance safer
-    def __init__(self, node, persistentDocument = None):
+    def __init__(self, node, persistentDocument):
         # inherit from DOMProxy.NodeProxy
         ManageableNode.inheritedAttribute('__init__')(self, node,
                                                       persistentDocument)
@@ -699,7 +700,7 @@
 
     implementation = theDOMImplementation
 
-    def __init__(self, node, persistentDocument = None):
+    def __init__(self, node, persistentDocument):
         ManageableNode.__init__(self, node, persistentDocument)
 
     def _get_implementation(self):