• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python werkzeug.url_decode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中werkzeug.url_decode函数的典型用法代码示例。如果您正苦于以下问题:Python url_decode函数的具体用法?Python url_decode怎么用?Python url_decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_extended_fb_token

def get_extended_fb_token(access_token):
    # print access_token
    payload = {'client_id': FB_CLIENT_ID, 'client_secret': FB_CLIENT_SECRET, 'grant_type': 'fb_exchange_token', 'fb_exchange_token': access_token}
    r = requests.get("https://graph.facebook.com/oauth/access_token", params=payload)
    try:
        access_token = url_decode(r.text).get('access_token')
    except Exception as e:
        print '(WARNING) Failed to parse retrieve long-lived access token', r.text
    print 'EXPIRES: ' + url_decode(r.text).get('expires')
    return access_token
开发者ID:iriswang,项目名称:mdfs,代码行数:10,代码来源:server.py


示例2: test_url_decoding

def test_url_decoding():
    """Test the URL decoding"""
    x = url_decode('foo=42&bar=23&uni=H%C3%A4nsel')
    assert x['foo'] == '42'
    assert x['bar'] == '23'
    assert x['uni'] == u'Hänsel'

    x = url_decode('foo=42;bar=23;uni=H%C3%A4nsel', separator=';')
    assert x['foo'] == '42'
    assert x['bar'] == '23'
    assert x['uni'] == u'Hänsel'

    x = url_decode('%C3%9Ch=H%C3%A4nsel', decode_keys=True)
    assert x[u'Üh'] == u'Hänsel'
开发者ID:t11e,项目名称:werkzeug,代码行数:14,代码来源:test_urls.py


示例3: cse_demande

def cse_demande():
    def mk_float(s):
        s = s.strip()
        return float(s) if s else 0

    data = url_decode(request.data)

    data['logement_gracieux'] = data['logement_gracieux'] == 'Oui'
    data['logement_montant'] = mk_float(data['logement_montant'])

    data['financement_famille'] = data['financement_famille'] == 'Oui'
    data['financement_famille_montant'] = mk_float(data['financement_famille_montant'])

    data['financement_autre'] = data['financement_autre'] == 'Oui'
    data['financement_autre_montant'] = mk_float(data['financement_autre_montant'])

    data['apl'] = data['apl'] == 'Oui'
    data['apl_montant'] = mk_float(data['apl_montant'])

    # data['boursier'] = data['boursier'] == 'Oui'
    data['boursier_montant'] = mk_float(data['boursier_montant'])

    print data.to_dict()
    demande = DossierCSE(**data.to_dict())
    demande.save()

    return jsonify(result='saved')
开发者ID:cynddl,项目名称:federation-backend,代码行数:27,代码来源:api.py


示例4: parse_response

def parse_response(resp, content, strict=False, content_type=None):
    """
    Parse the response returned by :meth:`OAuthRemoteApp.http_request`.
    """
    ct = resp.headers.get('content-type')
    if not ct and content.lower().strip().startswith('callback('):
        ct = 'application/json'
    if not ct:
        ct = content_type
    if not ct:
        ct = 'application/json'
    ct, options = parse_options_header(ct)

    if ct in ('application/json', 'text/javascript'):
        if content.lower().strip().startswith('callback('):
            content = content.strip().replace('callback(', '', 1).strip("); ")
        return json.loads(content)

    if ct in ('application/xml', 'text/xml'):
        return get_etree().fromstring(content)

    if ct != 'application/x-www-form-urlencoded' and strict:
        return content
    charset = options.get('charset', 'utf-8')
    return url_decode(content, charset=charset).to_dict()
开发者ID:archerhu,项目名称:flask-oauthlib,代码行数:25,代码来源:client.py


示例5: __call__

    def __call__(self, environ, start_response):
        if '_method' in environ.get('QUERY_STRING', ''):
            args = url_decode(environ['QUERY_STRING'])
            method = args.get('_method')
            if method:
                method = method.encode('ascii', 'replace')
                environ['REQUEST_METHOD'] = method
        return self.app(environ, start_response)

# class MethodRewriteMiddleware(object):
#     """Legacy Browser and HTTP REST Methods Support
#     For HTML form use:
#     <input type="hidden" name="_method" value="OPTIONS" />
#     """
#     HTTP_METHODS = ['GET', 'POST', 'PUT', 'DELETE',
#                     'HEAD', 'OPTIONS',
#                     'TRACE', 'CONNECT']

#     def __init__(self, app, input_name='_method'):
#         self.app = app
#         self.input_name = input_name

#     def __call__(self, environ, start_response):
#         request = Request(environ)

        if self.input_name in request.form:
            method = request.form[self.input_name].upper()

            if method in self.HTTP_METHODS:
                environ['REQUEST_METHOD'] = method

        return self.app(environ, start_response)
开发者ID:VPH-Share,项目名称:transmogrifier,代码行数:32,代码来源:helpers.py


示例6: url_add

def url_add(url=None, **kwargs):
    scheme, netloc, path, query, fragments = urlsplit(url or request.url)
    params = url_decode(query)
    for key, value in kwargs.items():
        if not value in params.getlist(key):
            params.add(key, value)
    return Markup(urlunsplit((scheme, netloc, path, url_encode(params), fragments)))
开发者ID:pborreli,项目名称:cada,代码行数:7,代码来源:views.py


示例7: url_equals

 def url_equals(to_check):
     if to_check[:4] != check_parts[:4]:
         return False
     args = url_decode(to_check[4])
     for key, value in args.iteritems():
         if check_query.get(key) != value:
             return False
     return True
开发者ID:DasIch,项目名称:solace,代码行数:8,代码来源:application.py


示例8: __call__

 def __call__(self, environ, start_response):
     if "METHOD_OVERRIDE" in environ.get("QUERY_STRING", ""):
         args = url_decode(environ["QUERY_STRING"])
         method = args.get("__METHOD_OVERRIDE__")
         if method:
             method = method.encode("ascii", "replace")
             environ["REQUEST_METHOD"] = method
     return self.app(environ, start_response)
开发者ID:Mondego,项目名称:pyreco,代码行数:8,代码来源:allPythonContent.py


示例9: in_url

def in_url(*args, **kwargs):
    scheme, netloc, path, query, fragments = urlsplit(request.url)
    params = url_decode(query)
    return (
        all(arg in params for arg in args) and
        all(key in params and params[key] == value
            for key, value in kwargs.items())
    )
开发者ID:odtvince,项目名称:udata,代码行数:8,代码来源:helpers.py


示例10: url_rewrite

def url_rewrite(url=None, **kwargs):
    scheme, netloc, path, query, fragments = urlsplit(url or request.url)
    params = url_decode(query)
    for key, value in kwargs.items():
        params.setlist(key,
                       value if isinstance(value, (list, tuple)) else [value])
    return Markup(urlunsplit((scheme, netloc, path, url_encode(params),
                  fragments)))
开发者ID:odtvince,项目名称:udata,代码行数:8,代码来源:helpers.py


示例11: __call__

 def __call__(self, environ, start_response):
     if 'METHOD_OVERRIDE' in environ.get('QUERY_STRING', ''):
         args = url_decode(environ['QUERY_STRING'])
         method = args.get('__METHOD_OVERRIDE__')
         if method:
             method = method.encode('ascii', 'replace')
             environ['REQUEST_METHOD'] = method
     return self.app(environ, start_response)
开发者ID:jkur,项目名称:mmm,代码行数:8,代码来源:wsgi.py


示例12: __call__

 def __call__(self, environ, start_response):
     if '__METHOD__' in environ.get('QUERY_STRING', ''):
         args = url_decode(environ['QUERY_STRING'])
         method = args.get('__METHOD__').upper()
         if method in ['GET', 'POST', 'PUT', 'DELETE']:
             method = method.encode('ascii', 'replace')
             environ['REQUEST_METHOD'] = method
     return self.app(environ, start_response)
开发者ID:MediaSapiens,项目名称:flask-social,代码行数:8,代码来源:app.py


示例13: get_redirect_target

    def get_redirect_target(self, invalid_targets=()):
        """Check the request and get the redirect target if possible.
        If not this function returns just `None`.  The return value of this
        function is suitable to be passed to `redirect`.
        """
        check_target = self.values.get('_redirect_target') or \
                       self.values.get('next') or \
                       self.referrer

        # if there is no information in either the form data
        # or the wsgi environment about a jump target we have
        # to use the target url
        if not check_target:
            return

        # otherwise drop the leading slash
        check_target = check_target.lstrip('/')

        root_url = self.url_root
        root_parts = urlparse(root_url)

        check_parts = urlparse(urljoin(root_url, check_target))
        check_query = url_decode(check_parts[4])

        def url_equals(to_check):
            if to_check[:4] != check_parts[:4]:
                return False
            args = url_decode(to_check[4])
            for key, value in args.iteritems():
                if check_query.get(key) != value:
                    return False
            return True

        # if the jump target is on a different server we probably have
        # a security problem and better try to use the target url.
        # except the host is whitelisted in the config
        if root_parts[:2] != check_parts[:2]:
            host = check_parts[1].split(':', 1)[0]
            for rule in settings.ALLOWED_REDIRECTS:
                if fnmatch(host, rule):
                    break
            else:
                return

        # if the jump url is the same url as the current url we've had
        # a bad redirect before and use the target url to not create a
        # infinite redirect.
        if url_equals(urlparse(self.url)):
            return

        # if the `check_target` is one of the invalid targets we also
        # fall back.
        for invalid in invalid_targets:
            if url_equals(urlparse(urljoin(root_url, invalid))):
                return

        return check_target
开发者ID:DasIch,项目名称:solace,代码行数:57,代码来源:application.py


示例14: create_engine

def create_engine(uri, relative_to=None, debug=False):
    """Create a new engine.  This works a bit like SQLAlchemy's
    `create_engine` with the difference that it automaticaly set's MySQL
    engines to 'utf-8', and paths for SQLite are relative to the path
    provided as `relative_to`. Also hooks in LookLively to catch MySQL's
    weird way of connection termination without termination.

    Furthermore the engine is created with `convert_unicode` by default.
    """

    # This is a good idea in any case
    options = {'convert_unicode': True}

    # special case sqlite.  We want nicer urls for that one.
    if uri.startswith('sqlite:'):
        match = _sqlite_re.match(uri)
        if match is None:
            raise ArgumentError('Could not parse rfc1738 URL')
        database, query = match.groups()
        if database is None:
            database = ':memory:'
        elif relative_to is not None:
            database = path.join(relative_to, database)
        if query:
            query = url_decode(query).to_dict()
        else:
            query = {}
        info = URL('sqlite', database=database, query=query)

    else:
        info = make_url(uri)

        # if mysql is the database engine and no connection encoding is
        # provided we set it to utf-8
        if info.drivername == 'mysql':
            info.query.setdefault('charset', 'utf8')
            options['listeners'] = [LookLively()]


    # alternative pool sizes / recycle settings and more.  These are
    # interpreter wide and not from the config for the following reasons:
    #
    # - system administrators can set it independently from the webserver
    #   configuration via SetEnv and friends.
    # - this setting is deployment dependent should not affect a development
    #   server for the same instance or a development shell
    for key in 'pool_size', 'pool_recycle', 'pool_timeout':
        value = os.environ.get("PYCLANSPHERE_" + key.upper())
        if value is not None:
            options[key] = int(value)

    # if debugging is enabled, hook the ConnectionDebugProxy in
    if debug:
        options['proxy'] = ConnectionDebugProxy()

    return sqlalchemy.create_engine(info, **options)
开发者ID:jokey2k,项目名称:pyClanSphere,代码行数:56,代码来源:database.py


示例15: insert_param_url_query_str

def insert_param_url_query_str(url_query_string, param_name, param_val):
    """
    Given an url query string this function:
    appends a new instance of param_name containing param_val (it doesn't remove existing ones)
    """
    if not param_name or not param_val:
        return url_query_string
    query_params = url_decode(url_query_string)
    query_params.update({param_name:param_val})
    return url_encode(query_params)
开发者ID:aaccomazzi,项目名称:adsabs,代码行数:10,代码来源:template_filters.py


示例16: __call__

    def __call__(self, environ, start_response):
        if self.query_param in environ.get('QUERY_STRING', ''):
            args = url_decode(environ['QUERY_STRING'])
            method = args.get(self.query_param)

            if method and method in self.VALID_METHODS:
                method = method.encode('ascii', 'replace')
                environ['REQUEST_METHOD'] = method

        return self.app(environ, start_response)
开发者ID:andrew-d,项目名称:docstore,代码行数:10,代码来源:middleware.py


示例17: keep_query

def keep_query(*args, **kw):
    if not args and not kw:
        args = ('*',)
    params = kw.copy()
    query_params = frozenset(werkzeug.url_decode(request.httprequest.query_string).keys())
    for keep_param in args:
        for param in fnmatch.filter(query_params, keep_param):
            if param not in params and param in request.params:
                params[param] = request.params[param]
    return werkzeug.urls.url_encode(params)
开发者ID:0k,项目名称:openerp-server,代码行数:10,代码来源:ir_ui_view.py


示例18: report_download

    def report_download(self, data, token):
        """This function is used by 'qwebactionmanager.js' in order to trigger the download of
        a pdf/controller report.

        :param data: a javascript array JSON.stringified containg report internal url ([0]) and
        type [1]
        :returns: Response with a filetoken cookie and an attachment header
        """
        requestcontent = simplejson.loads(data)
        url, type = requestcontent[0], requestcontent[1]
        try:
            if type == 'qweb-pdf':
                reportname = url.split('/report/pdf/')[1].split('?')[0]

                docids = None
                if '/' in reportname:
                    reportname, docids = reportname.split('/')

                if docids:
                    # Generic report:
                    response = super(Extension, self).report_routes(reportname, docids=docids, converter='pdf')
                    # response = self.report_routes(reportname, docids=docids, converter='pdf')
                    ##### FIX START: switch reportname with the evaluated attachment attribute of the action if available
                    docids = [int(i) for i in docids.split(',')]
                    report_obj = request.registry['report']
                    cr, uid, context = request.cr, request.uid, request.context
                    report = report_obj._get_report_from_name(cr, uid, reportname)
                    obj = report_obj.pool[report.model].browse(cr, uid, docids[0])
                    if hasattr(obj, 'name') and obj.name:
                        reportname = obj.name
                    ##### FIX END
                else:
                    # Particular report:
                    data = url_decode(url.split('?')[1]).items()  # decoding the args represented in JSON
                    response = super(Extension, self).report_routes(reportname, converter='pdf', **dict(data))
                    # response = self.report_routes(reportname, converter='pdf', **dict(data))

                response.headers.add('Content-Disposition', 'attachment; filename=%s.pdf;' % reportname)
                response.set_cookie('fileToken', token)
                return response
            elif type =='controller':
                reqheaders = Headers(request.httprequest.headers)
                response = Client(request.httprequest.app, BaseResponse).get(url, headers=reqheaders, follow_redirects=True)
                response.set_cookie('fileToken', token)
                return response
            else:
                return
        except Exception, e:
            se = _serialize_exception(e)
            error = {
                'code': 200,
                'message': "Odoo Server Error",
                'data': se
            }
            return request.make_response(html_escape(simplejson.dumps(error)))
开发者ID:MartinHeisig,项目名称:euratel-addons,代码行数:55,代码来源:controllers.py


示例19: parse_response

def parse_response(resp, content, strict=False):
    ct, options = parse_options_header(resp['content-type'])
    if ct in ('application/json', 'text/javascript'):
        return json.loads(content)
    elif ct in ('application/xml', 'text/xml'):
        return get_etree().fromstring(content)
    elif ct != 'application/x-www-form-urlencoded':
        if strict:
            return content
    charset = options.get('charset', 'utf-8')
    return url_decode(content, charset=charset).to_dict()
开发者ID:bjourne,项目名称:flask-oauth,代码行数:11,代码来源:flask_oauth.py


示例20: url_del

def url_del(url=None, *args, **kwargs):
    scheme, netloc, path, query, fragments = urlsplit(url or request.url)
    params = url_decode(query)
    for key in args:
        params.poplist(key)
    for key, value in kwargs.items():
        lst = params.poplist(key)
        if unicode(value) in lst:
            lst.remove(unicode(value))
        params.setlist(key, lst)
    return Markup(urlunsplit((scheme, netloc, path, url_encode(params), fragments)))
开发者ID:pborreli,项目名称:cada,代码行数:11,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python werkzeug.url_encode函数代码示例发布时间:2022-05-26
下一篇:
Python werkzeug.secure_filename函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap