Renderers are typically responsible for setting the content type on the request.response object themselves (if you haven't overridden it already). It'd be possible to write a view predicate that you can use next to the renderer argument, to make it more declarative.
class ResponseContentTypePredicate(object):
def __init__(self, config, val):
self.val = val
def text(self):
return 'response content-type = %s' % self.val
phash = text
def __call__(self, context, request):
if self.val is not None:
request.response.content_type = self.val
return True
config.add_view_predicate('response_content_type', ResponseContentTypePredicate)
@view_config(..., renderer='foo.mako', response_content_type='text/xml')
def ...
Anyway, just another option for you. This was written without the docs so expect an error somewhere!