[sqlalchemy] Re: Persistence of Python Objects with respect to the Session

2009-10-14 Thread Michael Bayer
mviamari wrote: Hello, I'm writing tests for my database, and I've run into a little bit of confusion. Say I have a class (we'll call it person) with two declared attributes that correspond to db columns: person.id person.name If I randomly assign a person object another attribute

[sqlalchemy] Re: Persistence of Python Objects with respect to the Session

2009-10-14 Thread mviamari
So if I read the documentation right, it appears that because I'm accessing the object via the primary key, it looks the object up locally (i.e. in the session) and returns that object. Other than doing a query/lookup on another attribute, how can I force it to create the object from the data in

[sqlalchemy] Re: Persistence of Python Objects with respect to the Session

2009-10-14 Thread mviamari
Michael, First, Thanks for your help. Second, something still isn't right. Here's the code in question: obj = Obj() org = Org() self.assertNotEqual(obj, None) self.assertNotEqual(org, None) #Nonsense_var is not representative of a table column,

[sqlalchemy] Re: Persistence of Python Objects with respect to the Session

2009-10-14 Thread mviamari
UPDATE: If I inject a session.expunge_all() before I query the DB for the objects again, the undeclared attribute is no longer present (i.e. I get the AttributeError I expect). On Oct 14, 7:08 pm, mviamari mviam...@gmail.com wrote: Michael, First, Thanks for your help. Second, something