Login

Judge login require by url

Author:
zuroc
Posted:
August 4, 2007
Language:
Python
Version:
.96
Tags:
url login require
Score:
5 (after 5 ratings)

Simple code , judge login require by url

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from django.conf.urls.defaults import patterns,url

#or use login_required
from django.contrib.admin.views.decorators import staff_member_required

def login_url(regex, view, *p,**args):
  """
  urlpatterns = patterns('',
      login_url(r'^$',direct_to_template, {'template': '1.html'}),
  )
  """
  return url(regex,staff_member_required(view),*p,**args)

def login_patterns(*p):
  """
    urlpatterns = login_patterns('',
        (r'^$',direct_to_template,{'template':'1.html'}),
    )
  """
  d=[]
  d.append(p[0])
  for i in xrange(1,len(p)):
      d.append(login_url(*p[i]))
  return patterns(*d)

More like this

  1. Require login by url by zbyte64 6 years, 6 months ago
  2. Require Login Middleware by mattgrayson 6 years, 3 months ago
  3. Enforce site wide login by chbrown 6 years, 4 months ago
  4. LoginRequiredMixin by slink 3 years, 9 months ago
  5. Require login across entire site by SuperJared 7 years, 11 months ago

Comments

Please login first before commenting.