当前位置: 首页>>代码示例>>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;未经允许,请勿转载。