PageRenderTime 269ms CodeModel.GetById 66ms app.highlight 84ms RepoModel.GetById 67ms app.codeStats 1ms

/tests/regressiontests/urlpatterns_reverse/namespace_urls.py

https://code.google.com/p/mango-py/
Python | 47 lines | 45 code | 2 blank | 0 comment | 0 complexity | 151d1a4776d6a0b19999b42b46af8667 MD5 | raw file
 1from django.conf.urls.defaults import *
 2from views import view_class_instance
 3
 4class URLObject(object):
 5    def __init__(self, app_name, namespace):
 6        self.app_name = app_name
 7        self.namespace = namespace
 8
 9    def urls(self):
10        return patterns('',
11            url(r'^inner/$', 'empty_view', name='urlobject-view'),
12            url(r'^inner/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='urlobject-view'),
13        ), self.app_name, self.namespace
14    urls = property(urls)
15
16testobj1 = URLObject('testapp', 'test-ns1')
17testobj2 = URLObject('testapp', 'test-ns2')
18default_testobj = URLObject('testapp', 'testapp')
19
20otherobj1 = URLObject('nodefault', 'other-ns1')
21otherobj2 = URLObject('nodefault', 'other-ns2')
22
23urlpatterns = patterns('regressiontests.urlpatterns_reverse.views',
24    url(r'^normal/$', 'empty_view', name='normal-view'),
25    url(r'^normal/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='normal-view'),
26
27    url(r'^mixed_args/(\d+)/(?P<arg2>\d+)/$', 'empty_view', name='mixed-args'),
28    url(r'^no_kwargs/(\d+)/(\d+)/$', 'empty_view', name='no-kwargs'),
29
30    url(r'^view_class/(?P<arg1>\d+)/(?P<arg2>\d+)/$', view_class_instance, name='view-class'),
31
32    (r'^unnamed/normal/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view'),
33    (r'^unnamed/view_class/(?P<arg1>\d+)/(?P<arg2>\d+)/$', view_class_instance),
34
35    (r'^test1/', include(testobj1.urls)),
36    (r'^test2/', include(testobj2.urls)),
37    (r'^default/', include(default_testobj.urls)),
38
39    (r'^other1/', include(otherobj1.urls)),
40    (r'^other2/', include(otherobj2.urls)),
41
42    (r'^ns-included1/', include('regressiontests.urlpatterns_reverse.included_namespace_urls', namespace='inc-ns1')),
43    (r'^ns-included2/', include('regressiontests.urlpatterns_reverse.included_namespace_urls', namespace='inc-ns2')),
44
45    (r'^included/', include('regressiontests.urlpatterns_reverse.included_namespace_urls')),
46
47)