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


Python urls.url_quote方法代码示例

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


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

示例1: post

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_quote [as 别名]
def post(self):
        if not may(CREATE):
            raise Forbidden()
        lang = request.form.get('language')
        content_type = self.TRANS.get(lang)
        content_type_hint = 'text/plain'
        filename = None
        t = request.form['code']
        # t is already unicode, but we want utf-8 for storage
        t = t.encode('utf-8')
        size = len(t)
        f = BytesIO(t)
        maxlife_timestamp = FOREVER
        name = create_item(f, filename, size, content_type, content_type_hint,
                           maxlife_stamp=maxlife_timestamp)
        return redirect_next('bepasty.display', name=name, _anchor=url_quote(filename)) 
开发者ID:bepasty,项目名称:bepasty-server,代码行数:18,代码来源:lodgeit.py

示例2: make_redirect_url

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_quote [as 别名]
def make_redirect_url(self, path_info, query_args=None, domain_part=None):
        """Creates a redirect URL.

        :internal:
        """
        suffix = ''
        if query_args:
            suffix = '?' + self.encode_query_args(query_args)
        return str('%s://%s/%s%s' % (
            self.url_scheme,
            self.get_host(domain_part),
            posixpath.join(self.script_name[:-1].lstrip('/'),
                           url_quote(path_info.lstrip('/'), self.map.charset,
                                     safe='/:|+')),
            suffix
        )) 
开发者ID:googlearchive,项目名称:cloud-playground,代码行数:18,代码来源:routing.py

示例3: get_query_string

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_quote [as 别名]
def get_query_string(environ):
    """Returns the `QUERY_STRING` from the WSGI environment.  This also takes
    care about the WSGI decoding dance on Python 3 environments as a
    native string.  The string returned will be restricted to ASCII
    characters.

    .. versionadded:: 0.9

    :param environ: the WSGI environment object to get the query string from.
    """
    qs = wsgi_get_bytes(environ.get('QUERY_STRING', ''))
    # QUERY_STRING really should be ascii safe but some browsers
    # will send us some unicode stuff (I am looking at you IE).
    # In that case we want to urllib quote it badly.
    return try_coerce_native(url_quote(qs, safe=':&%=+$!*\'(),')) 
开发者ID:jpush,项目名称:jbox,代码行数:17,代码来源:wsgi.py

示例4: build

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_quote [as 别名]
def build(self, values, append_unknown=True):
        """Assembles the relative url for that rule and the subdomain.
        If building doesn't work for some reasons `None` is returned.

        :internal:
        """
        tmp = []
        add = tmp.append
        processed = set(self.arguments)
        for is_dynamic, data in self._trace:
            if is_dynamic:
                try:
                    add(self._converters[data].to_url(values[data]))
                except ValidationError:
                    return
                processed.add(data)
            else:
                add(url_quote(to_bytes(data, self.map.charset), safe='/:|+'))
        domain_part, url = (u''.join(tmp)).split(u'|', 1)

        if append_unknown:
            query_vars = MultiDict(values)
            for key in processed:
                if key in query_vars:
                    del query_vars[key]

            if query_vars:
                url += u'?' + url_encode(query_vars, charset=self.map.charset,
                                         sort=self.map.sort_parameters,
                                         key=self.map.sort_key)

        return domain_part, url 
开发者ID:jpush,项目名称:jbox,代码行数:34,代码来源:routing.py

示例5: to_url

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_quote [as 别名]
def to_url(self, value):
        return url_quote(value, charset=self.map.charset) 
开发者ID:jpush,项目名称:jbox,代码行数:4,代码来源:routing.py

示例6: quote

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_quote [as 别名]
def quote(self, value):
        if self.has_slug:
            return self.model.slug.slugify(value)
        else:
            return url_quote(value) 
开发者ID:opendatateam,项目名称:udata,代码行数:7,代码来源:routing.py

示例7: build

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_quote [as 别名]
def build(self, values, append_unknown=True):
        """Assembles the relative url for that rule and the subdomain.
        If building doesn't work for some reasons `None` is returned.

        :internal:
        """
        tmp = []
        add = tmp.append
        processed = set(self.arguments)
        for is_dynamic, data in self._trace:
            if is_dynamic:
                try:
                    add(self._converters[data].to_url(values[data]))
                except ValidationError:
                    return
                processed.add(data)
            else:
                add(url_quote(to_bytes(data, self.map.charset), safe='/:|+'))
        domain_part, url = (u''.join(tmp)).split(u'|', 1)

        if append_unknown:
            query_vars = MultiDict(values)
            for key in processed:
                if key in query_vars:
                    del query_vars[key]

            if query_vars:
                url += u'?' + url_encode(query_vars, charset=self.map.charset,
                                        sort=self.map.sort_parameters,
                                        key=self.map.sort_key)

        return domain_part, url 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:34,代码来源:routing.py

示例8: send_file_inline

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_quote [as 别名]
def send_file_inline(filename):
    """Send a file inline, including the original filename.

    Ref: http://test.greenbytes.de/tech/tc2231/.
    """
    try:
        response = send_file(filename)
    except FileNotFoundError:
        return abort(404)
    basename = os.path.basename(filename)
    cont_disp = f"inline; filename*=UTF-8''{url_quote(basename)}"
    response.headers["Content-Disposition"] = cont_disp
    return response 
开发者ID:beancount,项目名称:fava,代码行数:15,代码来源:__init__.py


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