Previously Chris McDonough wrote:
> On 5/26/09 4:07 AM, Chris McDonough wrote:
> > On 5/26/09 3:52 AM, Wichert Akkerman wrote:
> >> Previously Chris McDonough wrote:
> >>>        def remember(self, principal, token):
> >>>            """ Return a set of headers suitable for 'remembering' the
> >>>            principal on subsequent requests """
> >>>
> >>>        def forget():
> >>>            """ Return a set of headers suitable for 'forgetting' the
> >>>            current user on subsequent requests"""
> >> It would be nice if there was also a handy utility function to apply
> >> those headers to a response. I suspect that code is often repeated now.
> 
> Oops, missed this one...
> 
> This might mean the difference between:
> 
> from repoze.bfg.security import logout
> 
> def someview(context, request):
>      response = render_template_to_response('some.pt')
>      logout(response)
>      return response
> 
> vs.
> 
> from repoze.bfg.security import forget
> 
> def someview(context, request):
>      response = render_template_to_response('some.pt')
>      headers = forget()
>      response.headerlist.extend(headers)
>      return response

The first variant feels better. I can not see a use case where you would
ever want to manipulate the headers returned by logout()/remember()
before adding them to the response, so folding the response header
updating into the function itself makes sense. Saves one often
duplicated line of code.

> But since BFG doesn't have a global response object like Pylons does, it's 
> not 
> possible to do:
> 
> def someview(context, request):
>      logout()
>      return render_template_to_response('some.pt')
> 
> .. if that's what you mean.

Luckily that is not what I meant :)

Wichert.

-- 
Wichert Akkerman <wich...@wiggy.net>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to