Pylons/pyramid — pull request #1007 by jvanasco (2013-04-29 22:14:13+00:00)
Title: html_render_factory and easier support for custom content/type render factories

I made this patch earlier today, which I ended up not needing , because i just needed to `return Response(string)` , but I wanted to submit this anyways. it might make be useful to someone else. it also might be a very stupid patch.

I refactored `string_render_factory` into `abstract_renderer_factory`, which accepts and uses a `default_content_type`

This makes the following 2 renderers a one-liner, and also makes it trivial to create new renderers that accept strings and do the correct content-type setting.

* `string_renderer_factory` returns `abstract_renderer_factory(info,default_content_type='text/plain')`
* `html_renderer_factory` returns `abstract_renderer_factory(info,default_content_type='text/html')`

now you could conceivably do things like:

def ical_renderer_factory(info):
return abstract_renderer_factory(info,default_content_type='text/calendar')

return render_to_response( 'ical', text, request=request )

this probably makes `@view_config( 'ical'....` easy too, but i never use that context so don't know how to test.