Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion when is a Context Processor called?

Received: by 10.14.203.7 with SMTP id e7mr22226766eeo.4.1349785295144;
        Tue, 09 Oct 2012 05:21:35 -0700 (PDT)
X-BeenThere: django-users@googlegroups.com
Received: by 10.14.194.70 with SMTP id l46ls3891977een.9.gmail; Tue, 09 Oct
 2012 05:20:08 -0700 (PDT)
Received: by 10.14.199.6 with SMTP id w6mr10253297een.0.1349785208787;
        Tue, 09 Oct 2012 05:20:08 -0700 (PDT)
Received: by 10.14.199.6 with SMTP id w6mr10253296een.0.1349785208771;
        Tue, 09 Oct 2012 05:20:08 -0700 (PDT)
Return-Path: <stefano.tranquill...@gmail.com>
Received: from mail-ee0-f45.google.com (mail-ee0-f45.google.com [74.125.83.45])
        by gmr-mx.google.com with ESMTPS id d5si4608113eep.0.2012.10.09.05.20.08
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 09 Oct 2012 05:20:08 -0700 (PDT)
Received-SPF: pass (google.com: domain of stefano.tranquill...@gmail.com designates 74.125.83.45 as permitted sender) client-ip=74.125.83.45;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.tranquill...@gmail.com designates 74.125.83.45 as permitted sender) smtp.mail=stefano.tranquill...@gmail.com; dkim=pass header...@gmail.com
Received: by mail-ee0-f45.google.com with SMTP id b47so3378268eek.4
        for <django-users@googlegroups.com>; Tue, 09 Oct 2012 05:20:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :content-type;
        bh=dudtcV9RtrJrR1YYWcji++ztOqHqwKQTaC1GEsc+tAw=;
        b=ozHNCC7dbJGlxl4rOhK+2vhETlWmNjIXtuabQNdc4dwYRY0m5waJsktog30vpw8cXz
         sMfHeRKLCWBWAOHmF3WMwL6OwIClJ6/VvPLj39GfEzoMuN4hsqccXB82E3Qh8GOlfzZs
         H8AE4LoWeRBf1PMjeF2aRnFvlha3q21Sd1eAjBxZHQjtXHmSievN4OzJ7K8mvSfClEKo
         vaN64QS/eEy2mlLIljTkTLI8Q2+GCLSab4/jHJz80A2hVwHw2LKHR4Q+XZGt077Q5p8/
         v4Op2wsSvUvienE6QbRhp+2WqIG8MVHVG5B8/u4Kek5QajzdiJzkwnPl1sYnAIeEoM/A
         ezGw==
Received: by 10.14.0.68 with SMTP id 44mr6148613eea.1.1349785208557; Tue, 09
 Oct 2012 05:20:08 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.14.4.199 with HTTP; Tue, 9 Oct 2012 05:19:48 -0700 (PDT)
In-Reply-To: <CAFHbX1+TJKk9gNFGkUNbsPGm5mBGB0vTYW9KRkBNt1z5TDa...@mail.gmail.com>
References: <CAPQ1=kAbvkcWeFEFf1dmLEDQsZiEwzbbm+Q3K9yBXSojpcF...@mail.gmail.com>
 <d76070d7-de4f-4869-a674-aa143e20047f@googlegroups.com> <830576f3-8d11-4c48-a040-f3bf77593b6e@googlegroups.com>
 <CAFHbX1+TJKk9gNFGkUNbsPGm5mBGB0vTYW9KRkBNt1z5TDa...@mail.gmail.com>
From: Stefano Tranquillini <stefano.tranquill...@gmail.com>
Date: Tue, 9 Oct 2012 14:19:48 +0200
Message-ID: <CAPQ1=kAgTNJrwKDMSnZqMDRvbYuk82=mN5wf2JMEOGDkvf6...@mail.gmail.com>
Subject: Re: when is a Context Processor called?
To: django-users@googlegroups.com
Content-Type: multipart/alternative; boundary=047d7b622822e10f5204cb9f5bc1

--047d7b622822e10f5204cb9f5bc1
Content-Type: text/plain; charset=ISO-8859-1

ok,
but in this way when the user logs out i've to remove the object from the
request, right?
what if the user closes the browser?

On Tue, Oct 9, 2012 at 1:02 PM, Tom Evans <tevans...@googlemail.com> wrote:

> On Mon, Oct 8, 2012 at 3:28 PM, Stefano T
> <stefano.tranquill...@gmail.com> wrote:
> > Ok.
> > so basically they are called before the rendering of a template.
> >
> > How can i have an object stored in the request object (if possible)?
> >
> > Something that lets me to do, in a view: request.user_profile...
> >
>
> You can define a simple middleware to put attributes on a request. Eg:
>
> class MyMiddleware(object):
>   def process_request(request):
>     request.profile = None
>     if request.user.is_authenticated():
>       request.profile = request.user.get_profile()
>
> See the documentation on middleware:
>
> https://docs.djangoproject.com/en/1.4/topics/http/middleware/
>
> Note that anything you put in TEMPLATE_CONTEXT_PROCESSORS is run
> whenever you render a template, and anything in MIDDLEWARE_CLASSES
> will be run on each request, so make sure the things you do in those
> places are actually required every time you render a template /
> process a request.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Stefano

--047d7b622822e10f5204cb9f5bc1
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

ok,<div>but in this way when the user logs out i&#39;ve to remove the objec=
t from the request, right?</div><div>what if the user closes the browser?<b=
r><br><div class=3D"gmail_quote">On Tue, Oct 9, 2012 at 1:02 PM, Tom Evans =
<span dir=3D"ltr">&lt;<a href=3D"mailto:tevans...@googlemail.com" target=3D=
"_blank">tevans...@googlemail.com</a>&gt;</span> wrote:<br>

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">On Mon, Oct 8, 2012 at 3:28 PM, Stefano T<br=
>
<div class=3D"im">&lt;<a href=3D"mailto:stefano.tranquill...@gmail.com">ste=
fano.tranquill...@gmail.com</a>&gt; wrote:<br>
&gt; Ok.<br>
&gt; so basically they are called before the rendering of a template.<br>
&gt;<br>
&gt; How can i have an object stored in the request object (if possible)?<b=
r>
&gt;<br>
&gt; Something that lets me to do, in a view: request.user_profile...<br>
&gt;<br>
<br>
</div>You can define a simple middleware to put attributes on a request. Eg=
:<br>
<br>
class MyMiddleware(object):<br>
=A0 def process_request(request):<br>
=A0 =A0 request.profile =3D None<br>
=A0 =A0 if request.user.is_authenticated():<br>
=A0 =A0 =A0 request.profile =3D request.user.get_profile()<br>
<br>
See the documentation on middleware:<br>
<br>
<a href=3D"https://docs.djangoproject.com/en/1.4/topics/http/middleware/" t=
arget=3D"_blank">https://docs.djangoproject.com/en/1.4/topics/http/middlewa=
re/</a><br>
<br>
Note that anything you put in TEMPLATE_CONTEXT_PROCESSORS is run<br>
whenever you render a template, and anything in MIDDLEWARE_CLASSES<br>
will be run on each request, so make sure the things you do in those<br>
places are actually required every time you render a template /<br>
process a request.<br>
<br>
Cheers<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
Tom<br>
</font></span><div class=3D"HOEnZb"><div class=3D"h5"><br>
--<br>
You received this message because you are subscribed to the Google Groups &=
quot;Django users&quot; group.<br>
To post to this group, send email to <a href=3D"mailto:django-users@googleg=
roups.com">django-users@googlegroups.com</a>.<br>
To unsubscribe from this group, send email to <a href=3D"mailto:django-user=
s%2Bunsubscribe@googlegroups.com">django-users+unsubscribe@googlegroups.com=
</a>.<br>
For more options, visit this group at <a href=3D"http://groups.google.com/g=
roup/django-users?hl=3Den" target=3D"_blank">http://groups.google.com/group=
/django-users?hl=3Den</a>.<br>
<br>
</div></div></blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>=
Stefano<br>
</div>

--047d7b622822e10f5204cb9f5bc1--