Created
January 2, 2013 09:50
-
-
Save hirokiky/4433362 to your computer and use it in GitHub Desktop.
Django's View class to try using a new View.dispatch of this commit https://github.com/hirokiky/django/commit/e3399495dca9a727568626f64e2fa276c2857da9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.views.generic import View | |
from django.http.response import HttpResponse | |
def corn_predicate(request): | |
params = getattr(request, request.method) | |
corn = params.get('corn', None) | |
return corn == u'1' | |
class PonyView(View): | |
dispatch_config = {'get': {'get_corn_1': corn_predicate}} | |
def get(self, request): | |
return HttpResponse('pony') | |
def get_corn_1(self, request): | |
"""When request has corn=1.""" | |
return HttpResponse('pony with corn') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment