[lxml-dev] pickling ElementStringResult
Stefan Behnel
stefan_ml at behnel.de
Fri Jun 27 07:50:11 CEST 2008
Hi,
Martijn Faassen wrote:
> Previously, I'd get a string back and I could stuff that into the ZODB
> just fine - it was picklable. Now I get this and it can't be pickled, so
> the same code fails. Is it only xpath that is so affected or are there
> other operations where these things can be returned?
No, only for XPath results (wherever they occur).
> Another potential problem is that a smart string when held in an object
> database might keep the underlying XML document alive long past its
> intended lifetime.
>
> I was originally thinking about coming up with a special way to pickle
> these smart strings, but this actually leads me to prefer another
> solution: a flag that can be passed to xpath() that turns off the
> returning of smart strings at all.
Wouldn't it be enough to pickle the string subclass as a plain (unicode)
string? You would obviously loose information that way, but pickling the
string result together with the entire tree would be much more surprising IMHO.
Stefan
More information about the lxml-dev
mailing list