2005-08-06 04:50:19 +08:00
|
|
|
from django.core.urlresolvers import RegexURLPattern, RegexURLResolver
|
2005-07-13 09:25:57 +08:00
|
|
|
|
2007-04-01 15:25:20 +08:00
|
|
|
__all__ = ['handler404', 'handler500', 'include', 'patterns', 'url']
|
2005-07-13 09:25:57 +08:00
|
|
|
|
|
|
|
handler404 = 'django.views.defaults.page_not_found'
|
|
|
|
handler500 = 'django.views.defaults.server_error'
|
|
|
|
|
|
|
|
include = lambda urlconf_module: [urlconf_module]
|
|
|
|
|
2007-04-01 15:25:20 +08:00
|
|
|
def patterns(prefix, *args):
|
2005-07-13 09:25:57 +08:00
|
|
|
pattern_list = []
|
2007-04-01 15:25:20 +08:00
|
|
|
for t in args:
|
|
|
|
if isinstance(t, (list, tuple)):
|
|
|
|
pattern_list.append(url(prefix=prefix, *t))
|
2005-07-13 09:25:57 +08:00
|
|
|
else:
|
2007-04-01 15:25:20 +08:00
|
|
|
pattern_list.append(t)
|
2005-07-13 09:25:57 +08:00
|
|
|
return pattern_list
|
2007-04-01 15:25:20 +08:00
|
|
|
|
|
|
|
def url(regex, view, kwargs=None, name=None, prefix=''):
|
|
|
|
if type(view) == list:
|
|
|
|
# For include(...) processing.
|
|
|
|
return RegexURLResolver(regex, view[0], kwargs)
|
|
|
|
else:
|
|
|
|
return RegexURLPattern(regex, prefix and (prefix + '.' + view) or view, kwargs, name)
|
|
|
|
|