Thanks for that example Ian. That's exactly it. I'm doing it from a
view decorator, but in effect it's the same. I need to call a function
from a view that needs to be able to set messages and potentially set
other cookies. I need the request object to set the messages, and the
response to set the cookies. This is already confusing in my opinion
as the messages framework potentially uses cookies, but that's beside
the point. If I get the response then pass it to my function, any
messages it sets will not be shown to the user on that response, but
would instead be saved and shown to the user on the subsequent
request. So I need a way to be able to cause cookies to be set from
such a function but before rendering the response. I thought about
having said function return some crazy list of dicts that I'd then
pass to response.set_cookie later, but that seemed even more hacky.

Jacob: I'm willing to accept that this situation is rare and that your
objections are valid. I can accomplish this via a middleware, and will
continue to do so. But I do still wish for a more simple and supported
way to deal with this situation. I can see Ian's delayed execution
pattern working just fine, but it's less readable in my opinion.

Thanks again,

Paul

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" 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/django-developers?hl=en.

Reply via email to