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


Python SimpleCookie.pop方法代码示例

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


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

示例1: middleware

# 需要导入模块: from Cookie import SimpleCookie [as 别名]
# 或者: from Cookie.SimpleCookie import pop [as 别名]
def middleware(environ, start_response):
    request = Request(environ).copy()

    response = request.get_response(django)

    if response.status_int != 305:
        return response(environ, start_response)
    data = json.loads(response.body)

    proxy = RemoteProxy([data['base_url']], rewrite_links=True)

    request.environ.pop("HTTP_ACCEPT_ENCODING", None)

    request.environ['SCRIPT_NAME'] = str(data['script_name']).rstrip("/")
    request.environ['PATH_INFO'] = "/" + str(data['path_info'].lstrip("/") )

    from Cookie import SimpleCookie as Cookie
    orig_cookie = cookie = request.environ.get('HTTP_COOKIE')
    if cookie:
        cookie = Cookie(cookie)
        for key in data['cookie_blacklist']:
            cookie.pop(key, None)
        cookiestr = []
        for key, value in cookie.items():
            cookiestr.append(value.OutputString())
        cookiestr = "; ".join(cookiestr)
        request.environ['HTTP_COOKIE'] = cookiestr

    request.environ['HTTP_X_THING_THEME'] = data['theme']

    filter = deliverance(proxy)

    def per_project_theme(environ):
        return "%(wsgi.url_scheme)s://%(HTTP_HOST)s%(HTTP_X_THING_THEME)s" % environ
    filter.default_theme = per_project_theme
    filter.rule_getter = TemplateRuleGetter(data['deliverance_rules'])
    filter.use_internal_subrequest = lambda *args, **kw: False

    base_subrequest = filter.build_external_subrequest
    def build_external_subrequest(url, orig_req, log):
        subreq = base_subrequest(url, orig_req, log)
        if url.endswith("/theme/") and orig_cookie:
            subreq.environ['HTTP_COOKIE'] = orig_cookie
        return subreq
    filter.build_external_subrequest = build_external_subrequest

    resp = request.get_response(filter)

    return resp(request.environ, start_response)
开发者ID:ejucovy,项目名称:thing,代码行数:51,代码来源:wsgi.py


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