To me, the answer to this question really lies in "what session
implementation are you using?"

For me, I've opted to use a session in a database on the server, which
allows me to set arbitrarily large items into the session without any real
penalty.

Then, for whatever you'd set a custom cookie for, I just set an attribute on
request.session.  Usually, this is something that would trigger some action
on the next page, so in the next page when I take the action, I delete the
session value just to keep things clean.

If you're not using server-side sessions, then you could do the same, but
remember to keep your values small.

Another alternative is to register a response callback on the request
(request.add_response_callback(...)) and thath method will be passed a
response object that you can then call set_cookie on no matter what the
actual response code is.

Steve

On Thu, Mar 10, 2011 at 1:07 PM, Seth <seedifferen...@gmail.com> wrote:

> I'm having the hardest time figuring out the best way to set cookies for my
> methods that don't return a true "Response" object (and therefore, don't
> have a set_cookie() method). Is there no such helper in the Pyramid stack?
> The closest thing I've found so far is the "Varying Attributes of Rendered
> Responses" section ( http://goo.gl/LwoPc ) but that doesn't really outline
> a helper method, and requires you to build the cookies manually and add them
> to the request.response_headerlist attribute.
>
> Are those of us not returning "real" Response objects stuck with building
> our cookie strings manually, or am I missing something here?
>
> Thanks,
> Seth
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-devel" group.
> To post to this group, send email to pylons-devel@googlegroups.com.
> To unsubscribe from this group, send email to
> pylons-devel+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pylons-devel?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to