MCPcopy Create free account
hub / github.com/ActiveState/code / wrap

Function wrap

recipes/Python/498217_custom_django_loginrequired/recipe-498217.py:3–7  ·  view source on GitHub ↗
(request, *args, **kwargs)

Source from the content-addressed store, hash-verified

1#the decorator
2def myuser_login_required(f):
3 def wrap(request, *args, **kwargs):
4 #this check the session if userid key exist, if not it will redirect to login page
5 if 'userid' not in request.session.keys():
6 return HttpResponseRedirect("/mysite/login")
7 return f(request, *args, **kwargs)
8 wrap.__doc__=f.__doc__
9 wrap.__name__=f.__name__
10 return wrap

Callers

nothing calls this directly

Calls 2

fFunction · 0.50
keysMethod · 0.45

Tested by

no test coverage detected