You can use a "view predicate" [1]. See Michael Merickel's answer to the same question [2]. Someone in that same thread also proposed setting it in the page template [3].
Hope this helps. [1] http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/hooks.html#view-and-route-predicates [2] https://groups.google.com/d/msg/pylons-discuss/xQVf71EBgeo/bzBgphIbNpkJ [3] https://groups.google.com/d/msg/pylons-discuss/xQVf71EBgeo/lLZDbRo3xIUJ On Wed, Apr 16, 2014 at 11:07 AM, Lie Ryan <[email protected]> wrote: > I have a single view configured to be rendered with multiple renderers > based on Accept header set: > > @view_config(accept="application/xml", renderer='template.xml.pt') > @view_config(accept="application/json", renderer='template.json.pt') > @view_config(accept="text/html", renderer='template.html.pt') > def myview(): > ... > > How do I set the Content-Type for the response? At the moment both views > gets rendered as text/html. > > I know that I can set request.response_content_type = '...', but that > still leaves me with the problem of detecting which view_config() line is > actually used for the current page. > > -- > 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]. > Visit this group at http://groups.google.com/group/pylons-discuss. > 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]. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.
