Login

Judge login require by url

Author:
zuroc
Posted:
August 4, 2007
Language:
Python
Version:
.96
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. Template tag - list punctuation for a list of items by shapiromatron 9 months, 3 weeks ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 10 months ago
  3. Serializer factory with Django Rest Framework by julio 1 year, 4 months ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 1 year, 5 months ago
  5. Help text hyperlinks by sa2812 1 year, 6 months ago

Comments

Please login first before commenting.