本文整理匯總了Python中django.core.urlresolvers.RegexURLPattern方法的典型用法代碼示例。如果您正苦於以下問題:Python urlresolvers.RegexURLPattern方法的具體用法?Python urlresolvers.RegexURLPattern怎麽用?Python urlresolvers.RegexURLPattern使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.core.urlresolvers
的用法示例。
在下文中一共展示了urlresolvers.RegexURLPattern方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_01_nb_of_route
# 需要導入模塊: from django.core import urlresolvers [as 別名]
# 或者: from django.core.urlresolvers import RegexURLPattern [as 別名]
def test_01_nb_of_route(self):
urls = ApiUrls.get_urls()
# check the nb of defined ressources should be the same as the
# number of route + 1 done by tastypie
self.assertEqual(len(urls), self.nb_route + 1)
self.assertTrue(isinstance(urls.pop(0), RegexURLPattern))
event_url = urls.pop(0)
self.assertTrue(isinstance(event_url, RegexURLResolver))
# XXX depend on the version of tastypie: only use one or both method:
# prepend_urls/override_urls
self.assertIn(len(event_url.url_patterns),
[self.nb_route_for_event, self.nb_route_for_event + 2])
for url in urls:
self.assertTrue(isinstance(url, RegexURLResolver))
self.assertEqual(len(url.url_patterns),
self.nb_default_route_by_ressource)
示例2: get_all_view_names
# 需要導入模塊: from django.core import urlresolvers [as 別名]
# 或者: from django.core.urlresolvers import RegexURLPattern [as 別名]
def get_all_view_names(self, urlpatterns, parent_regex=''):
for pattern in urlpatterns:
if isinstance(pattern, RegexURLResolver):
regex = '' if pattern._regex == "^" else pattern._regex
self.get_all_view_names(urlpatterns=pattern.url_patterns, parent_regex=parent_regex + regex)
elif isinstance(pattern, RegexURLPattern) and self._is_drf_view(pattern) and not self._is_format_endpoint(pattern):
api_endpoint = ApiEndpoint(pattern, parent_regex, self.drf_router)
self.endpoints.append(api_endpoint)
示例3: test_urls
# 需要導入模塊: from django.core import urlresolvers [as 別名]
# 或者: from django.core.urlresolvers import RegexURLPattern [as 別名]
def test_urls(self):
self.assertTrue(isinstance(api.urls, list))
for api_url in api.urls:
self.assertTrue(isinstance(api_url, RegexURLPattern))
示例4: find_url_callbacks
# 需要導入模塊: from django.core import urlresolvers [as 別名]
# 或者: from django.core.urlresolvers import RegexURLPattern [as 別名]
def find_url_callbacks(urls_module):
urlpatterns = urls_module.urlpatterns
hid_list = [urls_module.__name__]
for pattern in urlpatterns:
if isinstance(pattern, RegexURLPattern):
hid_list.append(pattern.callback.__module__)
elif isinstance(pattern, RegexURLResolver):
hid_list += find_url_callbacks(pattern.urlconf_module)
return hid_list