I'm personally not a big fan of this solution; I always store the bare
minimum in my sessions (makes it much easier to scale particularly if
you're throwing sessions into memcached if you have to load balance your
application) - if I *must* get the raw user object, I make an actual
request for it but typically I don't need it.
My user objects are simple: id, email, password, date_created,
date_modified and a few other flags. The user id, and email including
some basic AUTH information are stuffed into the session.
This way if I'm doing something specific in the app I can take advantage
of Traversal and make the object we are working on a resource (which
gives it to you as a context object) - then, using SQLAlchemy's
relationships and lazy loading I can get any dependent objects.
neurino <neu...@gmail.com> writes:
- --
Parnell "ixmatus" Springmeyer (http://ixmat.us)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
iQEcBAEBAgAGBQJOnFssAAoJEPvtlbpI1POLE3AH/1WZf8XPocprcBzX/Yfp6K+X
7MngqDLulUCqCLdNnnloiwEKIc2VTGdKlzxviT5BnQs9b19tgm0yILXeeceVZZxt
uXNiByK1hGY3fs0btpRwLB7Ulv6Rdu88coNQRHiSM0ZTDoawLAOk+MGuNt72E0B5
JnHWtcg8TG4oityd6j/fyyUzNWQerS4VFIV5CncOx9pScSiSi13wddkdAmUoTbJx
C9lJPxPkTOQZF28ZFj3OYfe7LauGELcJW3KO70eX3AbDOtaVMZQUc23MSu2UVKTn
tqJapNB6cd2dJIzMe0fjGgYoPja1BFPxcsE0XbAaHYRcwZFptJqYqZZcyzA7UVs=
=mz/z
-----END PGP SIGNATURE-----
--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To post to this group, send email to pylons-...@googlegroups.com.
To unsubscribe from this group, send email to pylons-discus...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
Pyramid has an awesome event system - you could easily setup an observer
for any event after a request but before rendering that can query the DB
and provide the user object.
Or you can go the base class view setup, I make all of my views classes
that extend a base view class - the base view, on every request, gets
the user's id from the session and provides a user object "self.user"
that all extending classes have access to... You could even put it in a
context object if you wanted.
Michael said it right, re-read that email.
neurino <neu...@gmail.com> writes:
- --
Parnell "ixmatus" Springmeyer (http://ixmat.us)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
iQEcBAEBAgAGBQJOnI34AAoJEPvtlbpI1POLXuoIAJ2QojCcV4VDh0Dm0WAZoavk
2owq3lQPZ4LUA6Ucsznv9opmHRYWJqQ4vbrEZ74H3+MYtLnWMAdxFB3q2Bq5NpK3
q5vtjUlmBJN3TpXjqryGJ5SFfk3oUS556GyHBYiYVRsLnOgVLgsj0uuv4zqKTapF
HzpymB9AYw/FAA0p7mHMi5vtaOiHGgVAXilLtlgSyM1z9Ne+rmCCArQ4PMGJLVmW
u5+qx46iJMna0sLXF/PxB35UJZfAAYzQa5VScaqbozxxF422lHddB8sXRCCfTbbB
iSuzUWoSsxf5+ellOTnPzqKNpUo8PqwDE1unkJ86zl8nrhbO5giWkHkSblRgvkw=
=QM6x
-----END PGP SIGNATURE-----
----
Michael
Um, is it possible that you're just getting the same page from your
browser cache, and therefore you're not hitting your server at all?
Have you tried shift-reload to see if that changes the behaviour?
-r
>
> I *don't want* at all to have session variables, I want a brand new
> queried request.user attribute each time the user loads its profile page.
>
> Thanks for your support
> neurino
>
>
>
> On Mon, Oct 17, 2011 at 7:24 PM, Michael Merickel <mmer...@gmail.com
> <mailto:mmer...@gmail.com>> wrote:
>
> 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
>
>
On 10/17/11 1:42 PM, neurino wrote:Um, is it possible that you're just getting the same page from your browser cache, and therefore you're not hitting your server at all? Have you tried shift-reload to see if that changes the behaviour?
Reading one more time Michael mail about the recipe:
> 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
*That's right the way I wanted it to work!*
So why if I reload a page my user is not queried again and stills to an
older state?
-r
I *don't want* at all to have session variables, I want a brand new
queried request.user attribute each time the user loads its profile page.
Thanks for your support
neurino
On Mon, Oct 17, 2011 at 7:24 PM, Michael Merickel <mmer...@gmail.com<mailto:mmer...@gmail.com>> wrote:
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
--
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
--
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+unsubscribe@googlegroups.com.