Rendering Helper

class cwf.views.rendering.Renderer[source]

Stateless class that simplifies usage of Django machinary for creating HttpResponse objects

An instantiated instance of this class is provided from cwf.views.rendering.renderer

http(*args, **kwargs)[source]

Return a HttpResponse object with the args and kwargs passed in

json(data)[source]

Return HttpResponse object with data dumped as a json string and a ‘application/javascript’ content_type

raise404()[source]

Raise a Http404

redirect(request, address, *args, **kwargs)[source]

Return a HttpResponseRedirect object

render(request, template, extra=None, mime='text/html', modify=None)[source]

Create a template, give it context and display as some mime type

Using a RequestContext object provided by self.request_context

If modify is provided and is callable then it will be used to modify the rendered template before creating the HttpResponse object

request_context(request, extra)[source]

Create a RequestContext object from the request and extra context provided.

If request has a state member, that will be used as default context , otherwise an empty dictionary is used, which is updated with the extra context provided.

simple_render(template, extra)[source]

Return the string from rendering specified template with a normal Context object

xml(data)[source]

Return HttpResponse object with data and a ‘application/xml’ content_type