On 10/19/07, Steve Potter <[EMAIL PROTECTED]> wrote:
>
> I would like to put together a piece of code that will test the
> referer for each request and if it matches a predefined pattern it
> would log that request as well as place a cookie on the client.
>
> Is custom middleware the correct place to do this?

Yes.  It sounds like you want to use process_request, do your
matching, and either log right then, or, if you need to wait for the
response for some reason, annotate the request with an extra
attribute, which a later process_* can check for.

> Also, I'm not exactly clear how response.set_cookie() works.  If I set
> a cookie in the middleware during a request, will it be passed to the
> client on the next response?

Use response.set_cookie in process_response.  That's always the
response passed back from the resolved view.  The cookie will be set
on *that* response, which is going on the wire back to the client just
after you return.  :)

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to