Menu

[r5933]: / trunk / gui / freeadmin / middleware.py  Maximize  Restore  History

Download this file

19 lines (16 with data), 587 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
from django.conf import settings
from django.contrib.auth.decorators import login_required
def public(f):
f.__is_public = True
return f
class RequireLoginMiddleware(object):
"""
Middleware component that makes every view be login_required
unless its decorated with @public
"""
def process_view(self,request,view_func,view_args,view_kwargs):
if request.path == settings.LOGIN_URL:
return None
if hasattr(view_func, '__is_public'):
return None
return login_required(view_func)(request,*view_args,**view_kwargs)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.