Just to (partially) answer myself -- by enabling db logging, I see
that the insertion is not seen in other db sessions because it gets
rolled back, most likely done in unittest's setUp() and tearDown() --
though I still don't understand the persistent user object thing

Jerry

On Dec 26, 10:02 pm, jerryji <[email protected]> wrote:
> BTW, during testing, this _persistent_ user object dropped my jaw --
>
> """> myapp/views/signup.py(73)signup_view()
>
> -> user = model.User(user_name=user_name, email=email,
> password=password)
> (Pdb) n
> (Pdb) user
> <pweb.models.User object at 0xbbb20ec>
> (Pdb) user = None
> (Pdb) user
> <pweb.models.User object at 0xbbb20ec>
> (Pdb) user2 = model.User(user_name=user_name, email=email,
> password=password)
> (Pdb) user2
> <pweb.models.User object at 0xbbb2f0c>
> (Pdb) user2 = None
> (Pdb) user2
> (Pdb)
> """
>
> Though I'm not sure if that's related to my problem at hand.
>
> Jerry
>
> On Dec 26, 9:55 pm, jerryji <[email protected]> wrote:
>
> > Hi,
>
> > I have been pulling my hair the whole day today: I have a web
> > application that runs fine, however, during unittest I noticed that
> > the test (PostgreSQL) database is not updated even after I issue the
> > flush() and see the SQL statement, which inserts fine by itself in
> > psql --
>
> > """
> > (Pdb) list
> >  73             user = model.User(user_name=user_name, email=email,
> > password=password)
> >  74
> >  75             dbsession = DBSession()
> >  76  ->              dbsession.add(user)
> >  77             try:
> >  78                 dbsession.flush()
> >  79             except:
> >  80                 raise
> > (Pdb) user
> > <myapp.models.User object at 0xa9b8c4c>
> > (Pdb) user.user_name, user.email, user.user_id
> > (u'test', u'[email protected]', u'f24a24217248480d90c1c370c103e07f')
> > (Pdb) n> myapp/views/signup.py(77)signup_view()
>
> > -> try:
> > (Pdb) n> myapp/views/signup.py(78)signup_view()
>
> > -> dbsession.flush()
> > (Pdb) n
> > ...INFO sqlalchemy.engine.base.Engine.0x...24ac INSERT INTO users
> > (user_id, user_name, email) VALUES (%(user_id)s, %(user_name)s, %
> > (email)s)
> > ...INFO sqlalchemy.engine.base.Engine.0x...24ac {'user_id':
> > u'f24a24217248480d90c1c370c103e07f', 'user_name': u'test', 'email':
> > u'[email protected]'}
> > """
>
> > I have dropped all the databases in my computer leaving only the test
> > db just to make absolute sure that I'm not connecting to one database
> > while looking into another.
>
> > What could have gone wrong?
>
> > Many thanks in advance!
>
> > Jerry

-- 
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.

Reply via email to