Created
January 30, 2013 15:37
-
-
Save tclancy/4674070 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def my_decorator(function=None): | |
def _decorator(view_function): | |
def _view(request, *args, **kwargs): | |
if not some_security_check(request.user): | |
return HttpResponseRedirect(reverse('auth_login')) | |
return view_function(request, *args, **kwargs) | |
_view.__name__ = view_function.__name__ | |
_view.__dict__ = view_function.__dict__ | |
_view.__doc__ = view_function.__doc__ | |
_view.__module__ = view_function.__module__ | |
return _view | |
if function is None: | |
return _decorator | |
else: | |
return _decorator(function) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ensures the proper info gets passed from the view so admindocs displays your view instead of a 404 of the decorator.