當前位置: 首頁>>代碼示例>>Python>>正文


Python resolvers.RegexPattern方法代碼示例

本文整理匯總了Python中django.urls.resolvers.RegexPattern方法的典型用法代碼示例。如果您正苦於以下問題:Python resolvers.RegexPattern方法的具體用法?Python resolvers.RegexPattern怎麽用?Python resolvers.RegexPattern使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.urls.resolvers的用法示例。


在下文中一共展示了resolvers.RegexPattern方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: url_object

# 需要導入模塊: from django.urls import resolvers [as 別名]
# 或者: from django.urls.resolvers import RegexPattern [as 別名]
def url_object(self) -> RegexPattern:
        return url(self.url, self.function) 
開發者ID:zulip,項目名稱:zulip,代碼行數:4,代碼來源:integrations.py

示例2: get_resolver

# 需要導入模塊: from django.urls import resolvers [as 別名]
# 或者: from django.urls.resolvers import RegexPattern [as 別名]
def get_resolver(cls):
        if '_routablepage_urlresolver' not in cls.__dict__:
            subpage_urls = cls.get_subpage_urls()
            cls._routablepage_urlresolver = URLResolver(RegexPattern(r'^/'), subpage_urls)

        return cls._routablepage_urlresolver 
開發者ID:wagtail,項目名稱:wagtail,代碼行數:8,代碼來源:models.py

示例3: get_resolver

# 需要導入模塊: from django.urls import resolvers [as 別名]
# 或者: from django.urls.resolvers import RegexPattern [as 別名]
def get_resolver(url, url_config):
        return URLResolver(RegexPattern(r'^{}'.format(url)), url_config) 
開發者ID:mwesterhof,項目名稱:wagtail_app_pages,代碼行數:4,代碼來源:compatibility.py

示例4: get_regex_pattern

# 需要導入模塊: from django.urls import resolvers [as 別名]
# 或者: from django.urls.resolvers import RegexPattern [as 別名]
def get_regex_pattern(urlpattern):
    """
    Get the raw regex out of the urlpattern's RegexPattern or RoutePattern. This is always a regular expression,
    unlike get_original_route above.
    """
    if hasattr(urlpattern, 'pattern'):
        # Django 2.0
        return urlpattern.pattern.regex.pattern
    else:
        # Django < 2.0
        return urlpattern.regex.pattern 
開發者ID:BeanWei,項目名稱:Dailyfresh-B2C,代碼行數:13,代碼來源:compat.py

示例5: make_url_resolver

# 需要導入模塊: from django.urls import resolvers [as 別名]
# 或者: from django.urls.resolvers import RegexPattern [as 別名]
def make_url_resolver(regex, urlpatterns):
    try:
        # Django 2.0
        from django.urls.resolvers import RegexPattern
        return URLResolver(RegexPattern(regex), urlpatterns)

    except ImportError:
        # Django < 2.0
        return URLResolver(regex, urlpatterns) 
開發者ID:BeanWei,項目名稱:Dailyfresh-B2C,代碼行數:11,代碼來源:compat.py

示例6: route

# 需要導入模塊: from django.urls import resolvers [as 別名]
# 或者: from django.urls.resolvers import RegexPattern [as 別名]
def route(self, request, path_components):
        if not self.live:
            raise Http404

        resolver = URLResolver(RegexPattern(r"^"), self.APP_PREFIX + self.app)
        path = request.path[len(self.url):]
        view, args, kwargs = resolver.resolve(path)

        self._view = view
        return (self, args, kwargs) 
開發者ID:Inboxen,項目名稱:Inboxen,代碼行數:12,代碼來源:models.py

示例7: test_str

# 需要導入模塊: from django.urls import resolvers [as 別名]
# 或者: from django.urls.resolvers import RegexPattern [as 別名]
def test_str(self):
        self.assertEqual(str(RegexPattern(_('^translated/$'))), '^translated/$') 
開發者ID:nesdis,項目名稱:djongo,代碼行數:4,代碼來源:test_resolvers.py

示例8: test_no_urls_exception

# 需要導入模塊: from django.urls import resolvers [as 別名]
# 或者: from django.urls.resolvers import RegexPattern [as 別名]
def test_no_urls_exception(self):
        """
        URLResolver should raise an exception when no urlpatterns exist.
        """
        resolver = URLResolver(RegexPattern(r'^$'), settings.ROOT_URLCONF)

        with self.assertRaisesMessage(
            ImproperlyConfigured,
            "The included URLconf 'urlpatterns_reverse.no_urls' does not "
            "appear to have any patterns in it. If you see valid patterns in "
            "the file then the issue is probably caused by a circular import."
        ):
            getattr(resolver, 'url_patterns') 
開發者ID:nesdis,項目名稱:djongo,代碼行數:15,代碼來源:tests.py

示例9: test_populate_concurrency

# 需要導入模塊: from django.urls import resolvers [as 別名]
# 或者: from django.urls.resolvers import RegexPattern [as 別名]
def test_populate_concurrency(self):
        """
        URLResolver._populate() can be called concurrently, but not more
        than once per thread (#26888).
        """
        resolver = URLResolver(RegexPattern(r'^/'), 'urlpatterns_reverse.urls')
        resolver._local.populating = True
        thread = threading.Thread(target=resolver._populate)
        thread.start()
        thread.join()
        self.assertNotEqual(resolver._reverse_dict, {}) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:13,代碼來源:tests.py

示例10: setUp

# 需要導入模塊: from django.urls import resolvers [as 別名]
# 或者: from django.urls.resolvers import RegexPattern [as 別名]
def setUp(self):
        urlconf = 'urlpatterns_reverse.urls_error_handlers'
        urlconf_callables = 'urlpatterns_reverse.urls_error_handlers_callables'
        self.resolver = URLResolver(RegexPattern(r'^$'), urlconf)
        self.callable_resolver = URLResolver(RegexPattern(r'^$'), urlconf_callables) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:7,代碼來源:tests.py


注:本文中的django.urls.resolvers.RegexPattern方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。