Re: RequestContext + Auth.middleware 'Accesses the Session' (aka LazyUser ain't that lazy)

2008-10-28 Thread bo

yes, it is "Lazy" in the "not evaluated until asked for sense" but

 File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/django/core/context_processors.py", line 20, in auth
if hasattr(request, 'user'):

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/django/contrib/auth/middleware.py", line 5, in __get__
request._cached_user = get_user(request)

  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/django/contrib/auth/__init__.py", line 83, in get_user
user_id = request.session[SESSION_KEY]
does the first session access then to user DB access

says that in essence, it will never be lazy if using the auth context
processor because it is always asked for, thus the LazyUser is just
overhead in this case.

and that happens before the messages are even considered.

bo



On Oct 28, 4:02 pm, SmileyChris <[EMAIL PROTECTED]> wrote:
> LazyUser is lazy and works fine. It's only triggered because of the
> messages part of the processor so that's the root of the problem
> (which is currently being talked about in another thread)
>
> On Oct 29, 4:51 am, bo <[EMAIL PROTECTED]> wrote:
>
> > well, not exactly.
>
> > the "LazyUser" is the thing that is not so lazy (yes i agree that the
> > messages are not lazy either), the Session is hit on the get_user
> > statement in auth() before the messages are even considered (see the
> > back trace).
>
> > The idea i am proposing is to make that entire
> > context_processors.auth() function a lazy entity so it only hits any
> > session/DB/messages/etc,etc when 'called' from inside a template or
> > view.
>
> > bo
>
> > On Oct 27, 6:58 pm, SmileyChris <[EMAIL PROTECTED]> wrote:
>
> > > This is exactly why my patch in the session messages ticket [1] makes
> > > the messages lazy.
>
> > > [1]http://code.djangoproject.com/ticket/4604
>
> > > On Oct 28, 1:59 pm, bo <[EMAIL PROTECTED]> wrote:
>
> > > > Actually i've found that the issue lies with the
> > > > TEMPLATE_CONTEXT_PROCESSORS
>
> > > > django.core.context_processors.auth
>
> > > > which does the get_and_delete messages bit ..
>
> > > > so i guess that is the proper behavior.
>
> > > > Sad to say that although my app can work around that issue (by using a
> > > > different messages mechanism thus i do not need
> > > > django.core.context_processors.auth) but "contrib.admin" screams if it
> > > > is not included.
>
> > > > So either this may be a documentation issue to say that "using
> > > > django.core.context_processors.auth will always insert a Vary: Cookie
> > > > header" or fix up admin to use the "request.user" instead of "user"
> > > > directly in the Context and then require
> > > > "django.core.context_processors.request" to always be included ...
>
> > > > bo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: RequestContext + Auth.middleware 'Accesses the Session' (aka LazyUser ain't that lazy)

2008-10-28 Thread SmileyChris

LazyUser is lazy and works fine. It's only triggered because of the
messages part of the processor so that's the root of the problem
(which is currently being talked about in another thread)

On Oct 29, 4:51 am, bo <[EMAIL PROTECTED]> wrote:
> well, not exactly.
>
> the "LazyUser" is the thing that is not so lazy (yes i agree that the
> messages are not lazy either), the Session is hit on the get_user
> statement in auth() before the messages are even considered (see the
> back trace).
>
> The idea i am proposing is to make that entire
> context_processors.auth() function a lazy entity so it only hits any
> session/DB/messages/etc,etc when 'called' from inside a template or
> view.
>
> bo
>
> On Oct 27, 6:58 pm, SmileyChris <[EMAIL PROTECTED]> wrote:
>
> > This is exactly why my patch in the session messages ticket [1] makes
> > the messages lazy.
>
> > [1]http://code.djangoproject.com/ticket/4604
>
> > On Oct 28, 1:59 pm, bo <[EMAIL PROTECTED]> wrote:
>
> > > Actually i've found that the issue lies with the
> > > TEMPLATE_CONTEXT_PROCESSORS
>
> > > django.core.context_processors.auth
>
> > > which does the get_and_delete messages bit ..
>
> > > so i guess that is the proper behavior.
>
> > > Sad to say that although my app can work around that issue (by using a
> > > different messages mechanism thus i do not need
> > > django.core.context_processors.auth) but "contrib.admin" screams if it
> > > is not included.
>
> > > So either this may be a documentation issue to say that "using
> > > django.core.context_processors.auth will always insert a Vary: Cookie
> > > header" or fix up admin to use the "request.user" instead of "user"
> > > directly in the Context and then require
> > > "django.core.context_processors.request" to always be included ...
>
> > > bo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: RequestContext + Auth.middleware 'Accesses the Session' (aka LazyUser ain't that lazy)

2008-10-28 Thread bo

well, not exactly.

the "LazyUser" is the thing that is not so lazy (yes i agree that the
messages are not lazy either), the Session is hit on the get_user
statement in auth() before the messages are even considered (see the
back trace).

The idea i am proposing is to make that entire
context_processors.auth() function a lazy entity so it only hits any
session/DB/messages/etc,etc when 'called' from inside a template or
view.

bo

On Oct 27, 6:58 pm, SmileyChris <[EMAIL PROTECTED]> wrote:
> This is exactly why my patch in the session messages ticket [1] makes
> the messages lazy.
>
> [1]http://code.djangoproject.com/ticket/4604
>
> On Oct 28, 1:59 pm, bo <[EMAIL PROTECTED]> wrote:
>
> > Actually i've found that the issue lies with the
> > TEMPLATE_CONTEXT_PROCESSORS
>
> > django.core.context_processors.auth
>
> > which does the get_and_delete messages bit ..
>
> > so i guess that is the proper behavior.
>
> > Sad to say that although my app can work around that issue (by using a
> > different messages mechanism thus i do not need
> > django.core.context_processors.auth) but "contrib.admin" screams if it
> > is not included.
>
> > So either this may be a documentation issue to say that "using
> > django.core.context_processors.auth will always insert a Vary: Cookie
> > header" or fix up admin to use the "request.user" instead of "user"
> > directly in the Context and then require
> > "django.core.context_processors.request" to always be included ...
>
> > bo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: RequestContext + Auth.middleware 'Accesses the Session' (aka LazyUser ain't that lazy)

2008-10-28 Thread Adam Gomaa

On Mon, Oct 27, 2008 at 8:59 PM, bo <[EMAIL PROTECTED]> wrote:
> thus i do not need
> django.core.context_processors.auth) but "contrib.admin" screams if it
> is not included.

I don't want to steer the thread off-topic, but I've been bitten by
this as well. My specific usecase is a project in which I subclass
User and would prefer to populate 'user' in the context with my own
subclass, but doing that would entail giving up the admin. It's
ultimately a problem of contrib.admin wanting a context processor when
I think it could just as easily be done by having contrib.admin pass
the context explicitly - wanting 'djagno.core.context_processors.auth'
is *not* a universal thing (per this thread - it causes an eager DB
hit), and it seems odd that admin would require it.

Adam

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: RequestContext + Auth.middleware 'Accesses the Session' (aka LazyUser ain't that lazy)

2008-10-27 Thread SmileyChris

This is exactly why my patch in the session messages ticket [1] makes
the messages lazy.

[1] http://code.djangoproject.com/ticket/4604

On Oct 28, 1:59 pm, bo <[EMAIL PROTECTED]> wrote:
> Actually i've found that the issue lies with the
> TEMPLATE_CONTEXT_PROCESSORS
>
> django.core.context_processors.auth
>
> which does the get_and_delete messages bit ..
>
> so i guess that is the proper behavior.
>
> Sad to say that although my app can work around that issue (by using a
> different messages mechanism thus i do not need
> django.core.context_processors.auth) but "contrib.admin" screams if it
> is not included.
>
> So either this may be a documentation issue to say that "using
> django.core.context_processors.auth will always insert a Vary: Cookie
> header" or fix up admin to use the "request.user" instead of "user"
> directly in the Context and then require
> "django.core.context_processors.request" to always be included ...
>
> bo
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---



Re: RequestContext + Auth.middleware 'Accesses the Session' (aka LazyUser ain't that lazy)

2008-10-27 Thread bo


Actually i've found that the issue lies with the
TEMPLATE_CONTEXT_PROCESSORS

django.core.context_processors.auth

which does the get_and_delete messages bit ..

so i guess that is the proper behavior.

Sad to say that although my app can work around that issue (by using a
different messages mechanism thus i do not need
django.core.context_processors.auth) but "contrib.admin" screams if it
is not included.

So either this may be a documentation issue to say that "using
django.core.context_processors.auth will always insert a Vary: Cookie
header" or fix up admin to use the "request.user" instead of "user"
directly in the Context and then require
"django.core.context_processors.request" to always be included ...

bo



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~--~~~~--~~--~--~---