[Twisted-Python] Sending domish.Element results to Unpersistable
Hi, 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'm considering reducing the Element instances to dicts but I may leave out details I may need in the future. Am I missing something? Enrique
On Mon, 2009-12-28 at 10:14 +0800, Enrique Samson Jr. wrote:
Hi,
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. ralphm
Hi,
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'm considering reducing the Element instances to dicts but I may leave out details I may need in the future.
Am I missing something? Perhaps I missed something, but IMHO the desire of sending parsed XML to another
On Mon, Dec 28, 2009 at 10:14:49AM +0800, Enrique Samson Jr. wrote: process just indicates some misdesign in the whole system ... PB allows you to build perfect machine-machine interface and unless you really need to pass XML chunks from outhere to your another process, never try to send around XML. If you have your data structures coming from XML - parse them and put into native python structures, they are so pretty and highlevel. By the way, SAX parser will help you better than DOM. If you have just an abstract XML - send it as unicode strings, don't parse it at all! If you store your program's data in XML DOM tree - you are most probably just abusing the whole idea of XML. Just think, what if you will need to change the XML parser (for perfomance or any other reason)? Alexey
Enrique
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- с уважением, Алексей Шпагин системный администратор цеха передачи данных технического центра телекоммуникаций ОАО "ВолгаТелеком" филиал в Удмуртской республике.
participants (3)
-
Enrique Samson Jr.
-
Ralph Meijer
-
twisted-web@udmvt.ru