Михаил Сахнов <[email protected]> wrote:
> Hi all. > > Environment: > Ubuntu Hardy, python2.5, sqlalchemy 0.5.2 > > I need to store serialized model in memcached. > If I store model to memcached and get this model from cache in the same > process everything looks fine. > But if I try to get model from cache in another process, I would have an > exception AttributeError. For example I try to unserialize model from pickle > string in ipython: > > > If I merge unserialized object with new session - it would work fine, but I > think, that it would make some queries in database. > How can I work with unserialized detached model? you’d need to get your object to be picklable; using methods like __reduce__ to help it along are options. I don’t have any code here to work with so I don’t know what specifically is wrong with it. However, SQLAlchemy 0.5.2 is *six years old* and is *extremely* bad in this area; at minimum, you’d want to get on 0.5.8 - if you look in http://docs.sqlalchemy.org/en/latest/changelog/changelog_05.html#change-0.5.8 there are many issues related to pickling that were fixed since 0.5.2 up to 0.5.8. While I understand the need to keep legacy systems running, I’d recommend against going much further with new development against an 0.5 codebase, that’s an extremely old version overall (not to mention Python 2.5 itself). Each new major release of SQLAlchemy improves performance and stability by huge leaps and bounds, so you are really missing out by continuing development on such an old version. The official “caching recipe” for SQLAlchemy was only first introduced in 0.6, when I first started doing extensive caching with SQLAlchemy on the job, and that took us through the 0.6 series to work out the kinks. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
