[lxml-dev] LXML and persistence with the ZODB?
Martijn Faassen
faassen at startifact.com
Fri Jun 27 17:55:06 CEST 2008
Martijn Faassen wrote:
> Marius Gedminas wrote:
>> On Thu, Jun 26, 2008 at 04:50:30PM -0500, Kenneth Miller wrote:
>>> Anyone done anything with this? I know it's simple enough to simply
>>> store an XML string, but has anyone bothered with storying lxml objects?
>> I wouldn't even try. ZODB is tricky to get right, especially if you're
>> trying to store mutable objects not designed to be stored in the ZODB.
>> And if future-compatibility with your old database is important, you
>> must commit to never renaming a class or an attribute, which is hard to do
>> when you rely on an external library without such commitment.
>
> Actually we're pickling a very well known data structure, XML, not a
> tree of elements. You could therefore write a pickler that takes
> advantage of this particular property. You'd only worry about the outer
> class name at most.
Checking the lxml.objectify code, it's indeed using this strategy. Since
libxml2 serialization and deserialization of XML is pretty fast, this
should be okay to use in a pickler.
Regards,
Martijn
More information about the lxml-dev
mailing list