Jens, I'm happy to review a PR. Also you are correct that if you return
`None` then the json renderer will kick in and use request.response. As far
as how this works with certain responses such as 201, 202, etc you will
probably want to be careful and return an explicit Response object in some
cases where you do not want an actual response body. For example, returning
`None` will result in a JSON null being rendered as the application/json
response body.

On Mon, Nov 6, 2017 at 5:34 PM, <[email protected]> wrote:

> Thanks Michael!
>
> Would you like me to submit a PR for the adjusted comment as per your
> suggestion?
>
> All of my (Cornice) view functions are decorated like so:
>
> @some_service.post(
>
>     content_type="application/json",
>
>     accept="application/json",
>
>     …
>     )
>
> which I think asks for the json renderer for responses. Unless, if I
> understand you correctly, the returned object is response object (instead
> of a dict or None or whatever).
>
> So should I then use
>
> def some_view_fun(request):
>     …
>     request.response.status = 201 # Created
>     return None
>
> instead of returning a HTTPCreated() here?
>
> Thank you!
> Jens
>
>
> On Thursday, November 2, 2017 at 1:48:02 AM UTC+10, Michael Merickel wrote:
>>
>> This renderer feature does not override the other one which is "if you
>> return a Response object then no renderers will be invoked". HTTPOk is a
>> Response subclass. This is covered in the first few paragraphs of the
>> renderer chapter. I'd be open to a PR that clarified the docs on this in
>> the section you linked since it does say "all views". It is infact "all
>> views that do not return something directly adaptable to a response such as
>> an implementer of IResponse, or an object whose type is registered as a
>> response adapter".
>>
>> https://docs.pylonsproject.org/projects/pyramid/en/latest/
>> narr/renderers.html#renderers
>>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/pylons-discuss/a89934fa-d7a5-487d-8790-0f370e999cbd%
> 40googlegroups.com
> <https://groups.google.com/d/msgid/pylons-discuss/a89934fa-d7a5-487d-8790-0f370e999cbd%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/CAKdhhwHEn%3DC-K-C8_gVT3jfn-%2BpQgpzLzbvNW3LTAOH6pgHDpg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to