[lxml-dev] LXML and persistence with the ZODB?

Martijn Faassen faassen at startifact.com
Fri Jun 27 17:41:14 CEST 2008


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.

That said, it'd still be tricky. It'd be nice to get a modification 
notification from lxml for instance, so that the ZODB knows that a tree 
has been changed and thus needs to be marked dirty so that a new 
transaction can be committed.

There are other tricky issues; if you use custom classes for your 
elements, you can't get away with just pickling the XML anymore, as 
you'd lose this information.

Regards,

Martijn



More information about the lxml-dev mailing list