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


Python wsgi.get_current_url函数代码示例

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


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

示例1: _get_current_url

    def _get_current_url(self, root_only=False, strip_querystring=False,
                         host_only=False, **kwargs):

        current_url = get_current_url(self.environ,
            root_only, strip_querystring, host_only)

        if (root_only or host_only) and not kwargs:
            return current_url

        qs = {}
        querystring = ''

        if not strip_querystring:
            qs = urlparse.parse_qs(''.join(current_url.split('?')[1:]))
            for arg in qs:
                qs[arg] = qs[arg][0]

        if kwargs:

            for arg in kwargs:
                qs[arg] = kwargs[arg]

            querystring = '?' + urllib.urlencode(qs)

        url = '%s' % get_current_url(self.environ, strip_querystring=True)

        if url[-1] != '/':
            url += '/'

        url += querystring

        return url
开发者ID:PabloRosales,项目名称:im-core-python,代码行数:32,代码来源:app.py

示例2: test_get_current_url_invalid_utf8

def test_get_current_url_invalid_utf8():
    env = create_environ()
    # set the query string *after* wsgi dance, so \xcf is invalid
    env["QUERY_STRING"] = "foo=bar&baz=blah&meh=\xcf"
    rv = wsgi.get_current_url(env)
    # it remains percent-encoded
    strict_eq(rv, u"http://localhost/?foo=bar&baz=blah&meh=%CF")
开发者ID:pallets,项目名称:werkzeug,代码行数:7,代码来源:test_wsgi.py

示例3: extract_wsgi

 def extract_wsgi(self, environ, headers):
     """Extract the server's set-cookie headers as cookies into the
     cookie jar.
     """
     self.extract_cookies(
         _TestCookieResponse(headers),
         U2Request(get_current_url(environ)),
     )
开发者ID:MHordecki,项目名称:hextrainer,代码行数:8,代码来源:test.py

示例4: handle_exception

 def handle_exception(self, exc_info, environ):
     event_id = capture('Exception',
         exc_info=exc_info,
         http={
             'method': environ.get('REQUEST_METHOD'),
             'url': get_current_url(environ, strip_querystring=True),
             'querystring': environ.get('QUERY_STRING'),
         },
     )
     return event_id
开发者ID:vvangelovski,项目名称:sentry,代码行数:10,代码来源:middleware.py

示例5: handle_exception

 def handle_exception(self, exc_info, environ):
     event_id = capture(
         "Exception",
         exc_info=exc_info,
         data={
             "sentry.interfaces.Http": {
                 "method": environ.get("REQUEST_METHOD"),
                 "url": get_current_url(environ, strip_querystring=True),
                 "querystring": environ.get("QUERY_STRING"),
             }
         },
     )
     return event_id
开发者ID:gandalfar,项目名称:sentry,代码行数:13,代码来源:middleware.py

示例6: login

 def login(self, env, req):
     data = req.form
     password = self.isso.conf.get("general", "admin_password")
     if data['password'] and data['password'] == password:
         response = redirect(re.sub(
             r'/login$',
             '/admin',
             get_current_url(env, strip_querystring=True)
         ))
         cookie = functools.partial(dump_cookie,
                                    value=self.isso.sign({"logged": True}),
                                    expires=datetime.now() + timedelta(1))
         response.headers.add("Set-Cookie", cookie("admin-session"))
         response.headers.add("X-Set-Cookie", cookie("isso-admin-session"))
         return response
     else:
         return render_template('login.html')
开发者ID:panta82,项目名称:isso,代码行数:17,代码来源:comments.py

示例7: login

 def login(self, env, req):
     if not self.isso.conf.getboolean("admin", "enabled"):
         return render_template('disabled.html')
     data = req.form
     password = self.isso.conf.get("admin", "password")
     if data['password'] and data['password'] == password:
         response = redirect(re.sub(
             r'/login$',
             '/admin',
             get_current_url(env, strip_querystring=True)
         ))
         cookie = functools.partial(dump_cookie,
                                    value=self.isso.sign({"logged": True}),
                                    expires=datetime.now() + timedelta(1))
         response.headers.add("Set-Cookie", cookie("admin-session"))
         response.headers.add("X-Set-Cookie", cookie("isso-admin-session"))
         return response
     else:
         isso_host_script = self.isso.conf.get("server", "public-endpoint") or local.host
         return render_template('login.html', isso_host_script=isso_host_script)
开发者ID:posativ,项目名称:isso,代码行数:20,代码来源:comments.py

示例8: get_wsgi_headers

    def get_wsgi_headers(self, environ):
        headers = Headers(self.headers)
        location = headers.get('location')
        if location is not None:
            if isinstance(location, unicode):
                location = iri_to_uri(location)
            headers['Location'] = urlparse.urljoin(get_current_url(environ, root_only=True), location)
        content_location = headers.get('content-location')
        if content_location is not None and isinstance(content_location, unicode):
            headers['Content-Location'] = iri_to_uri(content_location)
        if 100 <= self.status_code < 200 or self.status_code == 204:
            headers['Content-Length'] = '0'
        elif self.status_code == 304:
            remove_entity_headers(headers)
        if self.is_sequence and 'content-length' not in self.headers:
            try:
                content_length = sum((len(str(x)) for x in self.response))
            except UnicodeError:
                pass
            else:
                headers['Content-Length'] = str(content_length)

        return headers
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:23,代码来源:wrappers.py

示例9: url

 def url(self):
     return get_current_url(self.environ)
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:2,代码来源:wrappers.py

示例10: test_get_current_url_unicode

 def test_get_current_url_unicode(self):
     env = create_environ()
     env['QUERY_STRING'] = 'foo=bar&baz=blah&meh=\xcf'
     rv = wsgi.get_current_url(env)
     self.assert_strict_equal(rv,
         u'http://localhost/?foo=bar&baz=blah&meh=\ufffd')
开发者ID:TheWaWaR,项目名称:werkzeug,代码行数:6,代码来源:wsgi.py

示例11: uri

 def uri(self):
     return get_current_url(self._handle.environ)
开发者ID:Pholey,项目名称:python-armet,代码行数:2,代码来源:http.py

示例12: host_url

 def host_url(self):
     return get_current_url(self.environ, host_only=True)
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:2,代码来源:wrappers.py

示例13: url_root

 def url_root(self):
     return get_current_url(self.environ, True)
开发者ID:connoryang,项目名称:dec-eve-serenity,代码行数:2,代码来源:wrappers.py

示例14: test_get_current_url_unicode

def test_get_current_url_unicode():
    env = create_environ(query_string=u"foo=bar&baz=blah&meh=\xcf")
    rv = wsgi.get_current_url(env)
    strict_eq(rv, u"http://localhost/?foo=bar&baz=blah&meh=\xcf")
开发者ID:pallets,项目名称:werkzeug,代码行数:4,代码来源:test_wsgi.py

示例15: demo

 def demo(self, env, req):
     return redirect(get_current_url(env) + '/index.html')
开发者ID:jgosmann,项目名称:isso,代码行数:2,代码来源:comments.py


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