In login() what does Session.flush() and Session.commit() do then?
The changes are made to the database, I can see them using a database
client, but the second function cannot see them.

Additionally, if I make a change to the database directly using the
command line client, the changes cannot be seen by any of my functions
unless I call committ() before doing anything else.  The SQL
statements that SqlAlchemy is issuing are correct, I see them in the
debug output.



On Feb 17, 10:48 am, Wichert Akkerman <[email protected]> wrote:
> Previously Bryan wrote:
>
> > 1. Client calls login(), a new row is inserted in the token table.
> > 2. Client calls anotherFunction and the new row is not visible inside
> > that function
> > 3. If I place a Session.commit() in anotherFunction, then I can see
> > the row
>
> > def login(self, user, pass):
> >    ' Create new login entry that gives the client an id to pass back
> > to the server with each request
> >    newtoken = Token()
> >    Session.add(newtoken)
> >    Session.flush()
> >    Session.commit()
> >    ' Querying token table at this point shows all the tokens including
> > the newly added one
>
> > def anotherFunction(self, tokenId):
> >    ' If I list all rows in the token table at this point, the token
> > created in login() is not visible
> >    ' If I have a Session.commit() call before I query however, the row
> > is visible
>
> > Other details:
> > This is in an XMLRPCContoller.
> > I have a scoped_session setup.
>
> > Why is the second function looking at a stale version of the table?
>
> Because you haven't flushed the changes to the database. This is well
> documented in the SQLAlchemy documentation.
>
> Wichert.
>
> --
> Wichert Akkerman <[email protected]>    It is simple to make 
> things.http://www.wiggy.net/                  It is hard to make things 
> simple.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to