lxml and shelve

As described in a previous post I use shelve a pickle based python module to serialize my letter objects so they do not have to stay in memory and can be cashed to increase performance. The problem that I encountered is that pickle does not like lxml objects. The problem is also described by other people here: http://stackoverflow.com/questions/8274438/saving-an-lxml-etree-elementtree-object

So, the easiest for me was to switch back to strings and instead to pickle lxml objects, I pickle an xml string and an object method on my custumn letter object that transforms the string into an lxml _Element object.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s