Created
January 27, 2009 00:22
-
-
Save skabber/53073 to your computer and use it in GitHub Desktop.
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
# Just a reminder to myself of how to write a decorator class for Django urls. | |
from functools import update_wrapper | |
from django.http import Http404 | |
class IsGet(object): | |
def __call__(self, fn): | |
def decorate(request, *args, **kwargs): | |
return self.view_wrapper(request, fn, *args, **kwargs) | |
update_wrapper(self, fn) | |
return decorate | |
def view_wrapper(self, request, fn, *args, **kwargs): | |
if request.method == "GET": | |
return fn(request, *args, **kwargs) | |
else: | |
raise Http404() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment