from url_helper import execute, url_
import views
urlpatterns += patterns('',
url(r'^(?P<urls>.*)', execute, {'views': views}),
)
#/edit/4/ def edit(request, n="id"): html = """ edit object: %s""" % n return HttpResponse(html)
#url_(r'/space/:username/:tag/', views.url_), #/space/vicalloy/just/ def url_(request, username, tag): html = """ username: %s <br/> tag: %s""" % (username, tag) return HttpResponse(html)
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from django import http
from django.conf.urls.defaults import url
import re
def execute(request, urls, views):
"""
urls [methodName/]param1/param2/.../
methodName default index
"""
def get_method(views, methodName):
try:
return getattr(views, methodName)
except Exception, e:
return None
method = None
params = [e for e in urls.split("/") if e]
params.reverse()
if params:
method = get_method(views, params.pop())
if not method:
method = get_method(views, 'index')
if not method:
raise http.Http404('The requested admin page does not exist.')
return method(request, *params)
def url_(*args,**dic):
regex = args[0]
if regex[0] == "/":
regex = regex[1:]
regex = '^' + regex
regex = regex + '$'
regex = re.sub(":[^/]+",
lambda matchobj: "(?P<%s>[^/]+)" % matchobj.group(0)[1:],
regex)
return url(regex, *args[1:], **dic)
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有