PageRenderTime 21ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/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
Possible License(s): BSD-3-Clause
  1. from django.conf.urls.defaults import *
  2. from views import view_class_instance
  3. class URLObject(object):
  4. def __init__(self, app_name, namespace):
  5. self.app_name = app_name
  6. self.namespace = namespace
  7. def urls(self):
  8. return patterns('',
  9. url(r'^inner/$', 'empty_view', name='urlobject-view'),
  10. url(r'^inner/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='urlobject-view'),
  11. ), self.app_name, self.namespace
  12. urls = property(urls)
  13. testobj1 = URLObject('testapp', 'test-ns1')
  14. testobj2 = URLObject('testapp', 'test-ns2')
  15. default_testobj = URLObject('testapp', 'testapp')
  16. otherobj1 = URLObject('nodefault', 'other-ns1')
  17. otherobj2 = URLObject('nodefault', 'other-ns2')
  18. urlpatterns = patterns('regressiontests.urlpatterns_reverse.views',
  19. url(r'^normal/$', 'empty_view', name='normal-view'),
  20. url(r'^normal/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view', name='normal-view'),
  21. url(r'^mixed_args/(\d+)/(?P<arg2>\d+)/$', 'empty_view', name='mixed-args'),
  22. url(r'^no_kwargs/(\d+)/(\d+)/$', 'empty_view', name='no-kwargs'),
  23. url(r'^view_class/(?P<arg1>\d+)/(?P<arg2>\d+)/$', view_class_instance, name='view-class'),
  24. (r'^unnamed/normal/(?P<arg1>\d+)/(?P<arg2>\d+)/$', 'empty_view'),
  25. (r'^unnamed/view_class/(?P<arg1>\d+)/(?P<arg2>\d+)/$', view_class_instance),
  26. (r'^test1/', include(testobj1.urls)),
  27. (r'^test2/', include(testobj2.urls)),
  28. (r'^default/', include(default_testobj.urls)),
  29. (r'^other1/', include(otherobj1.urls)),
  30. (r'^other2/', include(otherobj2.urls)),
  31. (r'^ns-included1/', include('regressiontests.urlpatterns_reverse.included_namespace_urls', namespace='inc-ns1')),
  32. (r'^ns-included2/', include('regressiontests.urlpatterns_reverse.included_namespace_urls', namespace='inc-ns2')),
  33. (r'^included/', include('regressiontests.urlpatterns_reverse.included_namespace_urls')),
  34. )