On Friday 04 January 2008 14:44:32 Dave Harrison wrote: > On Friday 04 January 2008 23:32:21 Alexandre da Silva wrote: > > > Is there an easy way of flushing all objects that are > > > categorised as new in the session ?? > > > > I think you can use session.clear(), it will remove objects from > > session, and persistent objects will stay on database. > > > > Att > > > > Alexandre > > I had been using session.clear up until now, but as of 0.4.2 I've > found that I get this error for alot of my tests, > > object has no attribute '_sa_session_id' > > As background, the tests I have use a sqlite memory database, and > on setUp do a meta.create_all and on tearDown do a meta.drop_all > > I've assumed that this error is due to me leaving objects around in > the session, so my current theory is that I need to manually > expunge the objects I create at the end of the test.
the above means that the object has been removed from the session (which is what clear() does) BUT later someone (inside it) needs that session for something, e.g. to read some lazy-attribute or whatever. u may try to do clear_mappers() too - just a suggestion. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
