本文整理汇总了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)