Jonathan LaCour wrote:
> Michael Bayer wrote:
>
>> I think if Elixir doesn't support mapped entities being pickled,
>> or requires end-user __getstate__/__setstate__ (i think the
>> latter is the more reasonable requirement), it should be
>> explicit about this. pickling/unpickling is a basic necessity
>> particularly for people who are using file/memcached-based
>> caching strategies.
>
> You bet. If this is indeed the problem, then we need to file
> a ticket and fix it. I was arguing against monkeypatching the
> Entity class with the custom __getstate__ and __setstate__, but
> didn't make that clear.
My trivial testing seems to indicate that pickle works fine.
Granted, this is an extremely trivial example, but it seems to work
for me:
from elixir import *
from pickle import loads, dumps
class Person(Entity):
name = Field(String(64))
setup_all()
metadata.bind = 'sqlite:///'
metadata.create_all()
p = Person(name='Jonathan')
session.flush(); session.clear()
p = Person.get(1)
data = dumps(p)
session.clear()
p = loads(data)
p.name = 'New Name'
session.merge(p)
session.flush(); session.clear()
p = Person.get(1)
assert p.name == 'New Name'
And, I forgot that I have actually used Elixir with several cacheing
mechanisms that rely on pickle without any issues at all...
--
Jonathan LaCour
http://cleverdevil.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---