[XML-SIG] xml.dom.core.Document objects don't pickle (BUG WITH PATCH)

Lalo Martins lalo@hackandroll.org
Fri, 22 Sep 2000 03:27:49 -0300

Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

If you try to pickle a dom Document object you'll get a pickle
error because it stores the xml module as an attribute.

My reading of the Node class suggests you didn't intend to
pickle the Node attributes at all, just the _nodeData and the
Document reference, right?

To do that, it's not enough to just provide a __getinitargs__
method - you also need a __getstate__ which returns an empty
dictionary. I added one to my copy and it works fine.

          Hack and Roll  ( http://www.hackandroll.org )
            News for, uh, whatever it is that we are.

http://zope.gf.com.br/lalo           mailto:lalo@hackandroll.org
         pgp key: http://zope.gf.com.br/lalo/pessoal/pgp

Brazil of Darkness (RPG)    ---     http://zope.gf.com.br/BroDar

Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="xml.dom.core.diff"

--- core.py.orig	Fri Sep 22 02:39:45 2000
+++ core.py	Fri Sep 22 03:22:13 2000
@@ -318,6 +318,9 @@
     def __getinitargs__(self):
         return self._node, self._document
+    def __getstate__ (self):
+	return {} # no pickling
     # The following two methods implement handling of properties; references
     # to attributes such as .parentNode are redirected into calls to 
     # get_parentNode or set_parentNode.