pyramid.url

用于处理Pyramid中URL的实用函数

resource_url(resource, request, *elements, **kw)[源代码]

这是一个向后兼容函数。其结果与调用相同::

request.resource_url(resource, *elements, **kw)

pyramid.request.Request.resource_url() 更多信息。

route_url(route_name, request, *elements, **kw)[源代码]

这是一个向后兼容函数。其结果与调用相同::

request.route_url(route_name, *elements, **kw)

pyramid.request.Request.route_url() 更多信息。

current_route_url(request, *elements, **kw)[源代码]

这是一个向后兼容函数。其结果与调用相同::

request.current_route_url(*elements, **kw)

pyramid.request.Request.current_route_url() 更多信息。

route_path(route_name, request, *elements, **kw)[源代码]

这是一个向后兼容函数。其结果与调用相同::

request.route_path(route_name, *elements, **kw)

pyramid.request.Request.route_path() 更多信息。

current_route_path(request, *elements, **kw)[源代码]

这是一个向后兼容函数。其结果与调用相同::

request.current_route_path(*elements, **kw)

pyramid.request.Request.current_route_path() 更多信息。

static_url(path, request, **kw)[源代码]

这是一个向后兼容函数。其结果与调用相同::

request.static_url(path, **kw)

pyramid.request.Request.static_url() 更多信息。

static_path(path, request, **kw)[源代码]

这是一个向后兼容函数。其结果与调用相同::

request.static_path(path, **kw)

pyramid.request.Request.static_path() 更多信息。

urlencode(query, doseq=True, quote_via=<function quote_plus>)[源代码]

Python的stdlib的另一种实现 urllib.parse.urlencode() 中接受字符串键和值的函数 query DICT/SEQUENCE;所有字符串键和值在用于组成查询字符串之前首先转换为UTF-8。

价值 query 必须是表示键/值对的两个元组的序列 or 具有 .items() 方法,返回表示键/值对的两个元组的序列。

为了使调用约定向后兼容性最小,此版本的urlencode接受 但忽视 按惯例命名的第二个论点 doseq . 当 doseq 当序列显示为其中一个值时,为假。此版本始终在 doseq=True 模式,无论第二个参数的值是多少。

键和值都使用 quote_via 默认使用类似算法的函数 urllib.parse.quote_plus() 它将空格转换为“+”字符,“/”转换为“%2f”。

在 1.5 版本发生变更: 在键/值对中,如果值为 None 然后它将从生成的输出中删除。

在 1.9 版本发生变更: 增加了 quote_via 允许使用备用报价算法的参数。