[Twisted-Python] Sending domish.Element results to Unpersistable
twisted at ralphm.ik.nu
Mon Dec 28 03:54:55 EST 2009
On Mon, 2009-12-28 at 10:14 +0800, Enrique Samson Jr. wrote:
> I'm using PB to to send copies of domish.Element instances to another
> application. I just don't want to parse XML again and thought it would
> be better to send Element copies and save parsing on the other end. But
> receiving application just gets an Unpersistable.
I am not familiar enough with PB, but I assume that PB cannot serialize
objects of unknown classes without any help. In general, serialization
of XML is way more expensive than parsing, but I'd be very curious about
when this would actually become a problem.
> I'm considering reducing the Element instances to dicts but I may leave
> out details I may need in the future.
Except for parent, the instance variables mentioned in the docstring of
Element is all you need to remember. Note that this also requires
walking the DOM tree for the element you want to send over, and then
build up the tree on the other side. It might be just as expensive as
using an XML stream.
I've been thinking about building a (streaming) parser that would mostly
lex the incoming XML stream and only extract as much as needed for
routing, leaving the XML Stanza's payload as an unparsed string that can
be sent along further.
More information about the Twisted-Python