OK, sorry, one unittest I was too lazy to do was all the various "update"/"expunge"/"detached" combinations with Session....so i dont think anyone has exhaustively run through these until now. this was just a one liner in expunge(), try out rev 1698.
On Jul 10, 2006, at 6:11 PM, Michael Carter wrote: well theres session identifiers that will be stuck on the object if you dont expunge it, then when you go to put it into another session it should raise an error. Strangely enough, I don't get those errors. I'll see what the deal is there, but more important is the test transcript I've pasted below.
what is cache(u) doing exactly ? just saying expunge(x) then update (x) shouldnt be raising any errors. def cache(u): memcache.set(make_key(u), u) Also, given the earlier setup.py (I'll attach it so we're still on the same page) Here is a test transcript: >>> from setup import * >>> u = session.get(User, 1) [2006-07-10 15:07:53,763] [engine]: SELECT users.email AS users_email, users.id AS users_id, users.name AS users_name FROM users WHERE users.id = ? ORDER BY users.oid [2006-07-10 15:07:53,763] [engine]: [1] >>> session.identity_map.keys() [(<class 'setup.User'>, (1,), None)] >>> session.expunge(u) >>> session.identity_map.keys() [] >>> session.save_or_update(u) >>> session.identity_map.keys() [] >>> u.email = '[EMAIL PROTECTED]' Traceback (most recent call last): File "<stdin>", line 1, in ? File "c:\python\lib\site-packages\sqlalchemy-0.2.4-py2.4.egg\sqlalchemy\attrib utes.py", line 23, in __set__ self.set(None, obj, value) File "c:\python\lib\site-packages\sqlalchemy-0.2.4-py2.4.egg\sqlalchemy\attrib utes.py", line 180, in set ext.set(event or self, obj, value, old) File "c:\python\lib\site-packages\sqlalchemy-0.2.4-py2.4.egg\sqlalchemy\orm\un itofwork.py", line 55, in set sess._register_changed(obj) File "build\bdist.win32\egg\sqlalchemy\orm\session.py", line 349, in _register _changed File "build\bdist.win32\egg\sqlalchemy\orm\session.py", line 357, in _register _dirty File "c:\python\lib\site-packages\sqlalchemy-0.2.4-py2.4.egg\sqlalchemy\orm\un itofwork.py", line 184, in register_dirty self._validate_obj(obj) File "c:\python\lib\site-packages\sqlalchemy-0.2.4-py2.4.egg\sqlalchemy\orm\un itofwork.py", line 146, in _validate_obj raise InvalidRequestError("Detected a mapped object not present in the curre nt thread's Identity Map: '%s'. Use objectstore.import_instance() to place dese rialized instances or instances from other threads" % repr(obj._instance_key)) 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 Its not that it raises an error when i call session.save_or_update, its that it raises an error when I try to do anything with the object's attributes. -Michael
<setup.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
|