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 <wich...@wiggy.net>    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 pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to