Okay, I can't tell if you are misunderstanding that cookbook recipe, or if
you made the decision independent of that to store the user object in your
*session*. That is not what the recipe is advocating. It advocates a
mechanism to query the user the first time you access that property of the
request object and cache the result in memory for the lifetime of that
request.

Now if you decided that instead of querying the user from a database you
would get it from a session then that's fine, but you need to understand
that you are serializing a sqlalchemy object into a cookie. Thus when you go
back to load that object from the cookie, you need to reconnect it with the
database to make sure that it didn't change. This is done via the
DBSession.refresh(). The point here is that either way is valid, but you
*will* need to talk to the database once per-request if you want to use that
object with SQLAlchemy.

Another option is to only serialize the properties of the user that you care
about, then you can use those directly without having to talk to the
database. Then you're making the assumption that those properties didn't
change in the background.


-- 

Michael

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