two changes:

line 17 of setup.py:

users.mapper.compile()

line 15 of test2.py:

change:   session.save_or_update(u)

to:  u = session.merge(u)


On Jul 10, 2006, at 3:49 PM, Michael Carter wrote:

Ok, I've got a simple test case here.
There are three files:
setup.py
test1.py
test2.py

1. run setup.py to create the sqlite db file
2. run test1.py to create a user and pickle it
3. run test2.py to unpickle the user, check its attributes, and save it to the session
** Make sure test1 and test2 are run in seperate python processes

The assertion in test2.py fails for me. If i take it out, then the save_or_update fails with this error:

sqlalchemy.exceptions.InvalidRequestError: Detected a mapped object not present
in the current thread's Identity Map: '(<class 'setup.User'>, (1,), None)'.  Use
 objectstore.import_instance() to place deserialized instances or instances from
 other threads

On 7/10/06, Michael Carter <[EMAIL PROTECTED]> wrote:

er thats a little weird, when you unpickle the object, have all the
relevant classes had the same Mappers set up on them ?  the _state
attribute is a class-level property accessor that will only be there
if the class has been set up with a mapper (as are all the other
properties for which youre looking for default values).  the actual
data for _state is in the __dict__ as "_<classname>__sa_attr_state".
 
Yeah, I definitely have the relevant classes set up the same when I pickle and unpickle the object, with the same mapper set up on both.


this is all class-level stuff thats not related to the instance being
in or out of a Session.


I know its class-level stuff, but what it has to do with being in or out of a Session is that you can't put it into the session if it doesn't have a _state attribute.

I will attempt to write a simple test case.

-Michael

<setup.py>
<test1.py>
<test2.py>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
_______________________________________________
Sqlalchemy-users mailing list

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to