On Oct 21, 2006, at 1:37 AM, wyatt-bC wrote:
> And since I just can't get enough of this topic, here's why neither
> ``code`` nor ``status_code`` work as keyword args to render_response:
>
> render_response hands its *args and **kwargs off to response to do
> some
> work. The result from response is wrapped in a Response, but the
> leftover keyword args aren't passed to the Response.
Actually, render_response is directly equivalent to Response(render
(*args, **kargs)).
> I would humbly propose that those leftover keyword args could/
> should be
> passed on to Response, since render_response seems to be mainly a
> convenience wrapper around Response, and doing so would create a
> more-consistent API.
It's pretty much impossible to tell what arguments are "leftover".
render puts them all into the template's namespace and gives them to
the template engine.
> In my case, I happened to be looking through Paste a while back and
> saw
> ``code`` as an arg for Response (or WSGIResponse) and just assumed
> passing Response args into render_response would work.
If you want status code and render in one line:
return Response(render(*args, **kargs), code=204)
So put the render call in first, then add the code keyword, and
you're set. Here's the function def for Response to help out:
def __init__(self, content='', mimetype=None, code=200):
So you could set the mimetype in one too.
HTH,
Ben
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss
-~----------~----~----~----~------~----~------~--~---