What I guessed is my user attribute could be queried *once* *each time* a
page is _requested_.

What I find is this does not happen as reloading a page — which happens to
be returned by a different thread than the one that operated on the
collection — user attribute is steady at a precedent state and *not
retrieved again* upon new request.

Maybe I misunderstood the recipe but _why make a user available that way_
also for *any* attribute that can be edited?
As far as I know usually only userid is immutable and it's already
available.
Every other property could lead to my same problem: user changes email then
he finds it unchanged in next profile page...

So, is there an option for getting a new fresh user queried on each _page
request_ (honestly I thought it was the same as _request_ but I see it's
not)?

@Parnell: I *do need* full user data in each page as I need to show user
items in sidebar. Choices.

Thank you for your support
neurino


On Mon, Oct 17, 2011 at 7:24 PM, Michael Merickel <[email protected]>wrote:

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

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