1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | class View(object):
def __new__(cls, request, **kwargs):
obj = super(View, cls).__new__(cls)
return obj(request, **kwargs)
def __init__(self):
pass
def __call__(self, request, **kwargs):
pass
class GetPostView(View):
def __call__(self, request, **kwargs):
if request.POST:
return self.Post(request, **kwargs)
return self.Get(request, **kwargs)
def Get(self, request, **kwargs):
pass
def Post(self, request, **kwargs):
pass
|
More like this
- Simple views dispatcher by http methods by kmerenkov 3 years, 7 months ago
- Django & cache headers by ludvig.ericson 5 years, 11 months ago
- Django JSONP Decorator by cominatchu 2 years, 8 months ago
- SSL Redirect Middleware by zbyte64 4 years, 11 months ago
- RFC: Shim to allow view classes rather than functions by peterbraden 4 years, 3 months ago
Comments
Nice. Just what the doctor ordered.
#