-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 <[email protected]> writes:

> Well seems adding
>
>     DBSession.refresh(request.user)
>
> at the beginning of each view relying on `request.user` voids the
> problem.
>
> Now I wonder what's the benefit form having such attribute rather than
> querying each time for it in views.
>
> Thanks for your support
> neurino
>
>
> On Oct 17, 3:41 pm, neurino <[email protected]> wrote:
>> I implemented the procedure [explained here][1] to always have a User
>> Object available as a request attribute.
>>
>> It always worked good in development until I deployed it with Ubuntu -
>> MySQL
>>
>> Using SQLAlchemy User object has a `items` relationship like this:
>>
>>     mapper(User, users,
>>         properties={
>>             'items': relationship(Item, backref='user')
>>         })
>>
>> The crazy thing is that if I delete one or more `user.items` elements
>> in a view I get it back refreshing the page even if item has been
>> actually removed from db.
>>
>> Digging a bit and printing hex(id(request.user)) in templates I can
>> see there are 2 or more instances of User where only in one item has
>> been removed while it's still present in others.
>>
>> I can't understand where's the problem and how to solve it.
>>
>> Any help is really much appreciated.
>>
>> Thanks for your support
>> neurino
>>
>> [1]http://docs.pylonsproject.org/projects/pyramid_cookbook/dev/authentic...

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