Just a small example:
class MyView(ctn.AbstractCTNView):
ctn_accept_binding = {
'text/html': 'html_handler',
'text/*': 'plain_handler',
'*/*': 'plain_handler',
}
def html_handler(self, request, *args, **kwargs):
return HttpResponse('Hello World', mimetype='text/html')
def plain_handler(self, request, *args, **kwargs):
return HttpResponse('Hello World', mimetype='text/plain')
myview = oopviews.create_view(MyView)
This view would accept basically every request for text and give only for text/html provides a different output. Please note, though, that this is by no means a complete implementation of content-type negotiation. The specs also mention additional type-parameters, that are no further described, so I couldn't really add support for them. But for most cases, this implementation should suffice :-)
Google won't like it... What is that for?
Sept. 2, 2008, 8:59 a.m.
Uhm... what does Google not like about it?
Sept. 3, 2008, 9:22 a.m.