当前位置: 首页>>代码示例>>Python>>正文


Python urls.URLResolver方法代码示例

本文整理汇总了Python中django.urls.URLResolver方法的典型用法代码示例。如果您正苦于以下问题:Python urls.URLResolver方法的具体用法?Python urls.URLResolver怎么用?Python urls.URLResolver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.urls的用法示例。


在下文中一共展示了urls.URLResolver方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _get_reversed_urlpatterns

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import URLResolver [as 别名]
def _get_reversed_urlpatterns(urlpatterns=urlpatterns):
    """Yields a list of all URLs that we can reverse with default args."""
    for urlpattern in urlpatterns:
        if isinstance(urlpattern, URLPattern):
            try:
                path = reverse(urlpattern.name, *urlpattern.default_args)
            except NoReverseMatch:
                pass
            else:
                yield path
        elif isinstance(urlpattern, URLResolver):
            # handle recursive urlpattern definitions
            yield from _get_reversed_urlpatterns(urlpatterns=urlpattern.url_patterns) 
开发者ID:compserv,项目名称:hknweb,代码行数:15,代码来源:end_to_end_test.py

示例2: get_resolver

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import URLResolver [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: list_urls

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import URLResolver [as 别名]
def list_urls(lis, acc=None):
    # ripped from stackoverflow
    if acc is None:
        acc = []
    if not lis:
        return
    data = lis[0]
    if isinstance(data, URLPattern):
        yield acc + [str(data.pattern)]
    elif isinstance(data, URLResolver):
        yield from list_urls(data.url_patterns, acc + [str(data.pattern)])
    yield from list_urls(lis[1:], acc) 
开发者ID:jeffshek,项目名称:open,代码行数:14,代码来源:test_urls_configured.py

示例4: tenant_patterns

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import URLResolver [as 别名]
def tenant_patterns(*urls):
    """
    Add the tenant prefix to every URL pattern within this function.
    This may only be used in the root URLconf, not in an included URLconf.
    """
    return [URLResolver(TenantPrefixPattern(), list(urls))] 
开发者ID:lorinkoz,项目名称:django-pgschemas,代码行数:8,代码来源:urlresolvers.py

示例5: get_resolver

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import URLResolver [as 别名]
def get_resolver(url, url_config):
        return URLResolver(RegexPattern(r'^{}'.format(url)), url_config) 
开发者ID:mwesterhof,项目名称:wagtail_app_pages,代码行数:4,代码来源:compatibility.py

示例6: route

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import URLResolver [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


注:本文中的django.urls.URLResolver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。