本文整理汇总了Python中Cookie.SimpleCookie.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleCookie.iteritems方法的具体用法?Python SimpleCookie.iteritems怎么用?Python SimpleCookie.iteritems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cookie.SimpleCookie
的用法示例。
在下文中一共展示了SimpleCookie.iteritems方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __read_cookies
# 需要导入模块: from Cookie import SimpleCookie [as 别名]
# 或者: from Cookie.SimpleCookie import iteritems [as 别名]
def __read_cookies(self):
from Cookie import SimpleCookie
cookies_raw = SimpleCookie(self.get_env('HTTP_COOKIE'))
cookies = {}
for key, field in cookies_raw.iteritems():
cookies[key] = field.value
return Table(cookies, allow_duplicates = False, readonly = True)
示例2: cookies
# 需要导入模块: from Cookie import SimpleCookie [as 别名]
# 或者: from Cookie.SimpleCookie import iteritems [as 别名]
def cookies(self):
"""Stored Cookies."""
cookie = SimpleCookie()
cookie.load(self.environ.get('HTTP_COOKIE', ''))
result = {}
for key, value in cookie.iteritems():
result[key] = value.value.decode(self.charset, 'ignore')
return result
示例3: cookies
# 需要导入模块: from Cookie import SimpleCookie [as 别名]
# 或者: from Cookie.SimpleCookie import iteritems [as 别名]
def cookies(self):
from Cookie import SimpleCookie
cookie = SimpleCookie()
cookie.load(self.environ.get('HTTP_COOKIE', ''))
result = {}
for key, value in cookie.iteritems():
result[key] = value
return result
示例4: dump_cookies
# 需要导入模块: from Cookie import SimpleCookie [as 别名]
# 或者: from Cookie.SimpleCookie import iteritems [as 别名]
def dump_cookies(response = None):
if not response:
response = current_app.make_response('')
cookie_headers = (header[1] for header in response.headers if header[0] == 'Set-Cookie')
cookies = SimpleCookie()
for header in cookie_headers:
cookies.load(str(header))
cookies_dump = []
cookies_dump += dict(request.cookies),
cookies_dump += dict((name, dict(value=cookie.coded_value, **cookie))\
for name, cookie in cookies.iteritems()),
response.data = render_template('dump_cookies.html', dump=dumps(cookies_dump))
return response
示例5: rewrite
# 需要导入模块: from Cookie import SimpleCookie [as 别名]
# 或者: from Cookie.SimpleCookie import iteritems [as 别名]
def rewrite(self, cookie_str, header='Set-Cookie'):
results = []
cookie = SimpleCookie()
try:
cookie.load(cookie_str)
except CookieError:
return results
for name, morsel in cookie.iteritems():
morsel = self.rewrite_cookie(name, morsel)
if morsel:
results.append((header, morsel.OutputString()))
return results
示例6: parse_cookie
# 需要导入模块: from Cookie import SimpleCookie [as 别名]
# 或者: from Cookie.SimpleCookie import iteritems [as 别名]
def parse_cookie(environ):
"""Parse the cookie from request.
:return A dict(key: cookie name, value: the cookie value, not the instance of Morsel)
The cookies should be like this:
{'session_id': '1', 'test': 'xxx'}
"""
raw_cookie = SimpleCookie(environ.get('HTTP_COOKIE', ''))
cookie = {}
for key, value in raw_cookie.iteritems():
# cookie[key] = value.OutputString()[len(key)+1:]
cookie_str = value.OutputString()
k, v = parse_dict_string(cookie_str, split_sign='=', use_tuple=True)
cookie[k] = v
return cookie
示例7: generate_cookies
# 需要导入模块: from Cookie import SimpleCookie [as 别名]
# 或者: from Cookie.SimpleCookie import iteritems [as 别名]
def generate_cookies():
cookies = SimpleCookie()
cookies['view'] = view_to_str(options.view)
cookies['state'] = state_to_str(remote_state.state)
cookies['mode'] = mode_to_str(remote_state.mode)
cookies['temperature'] = temperature_to_str(remote_state.temperature)
cookies['fan_speed'] = fan_speed_to_str(remote_state.fan_speed)
cookies['full_effect'] = full_effect_to_str(remote_state.full_effect)
cookies['ion'] = ion_to_str(remote_state.ion)
cookies['swing'] = swing_to_str(remote_state.swing)
for (k, v) in cookies.iteritems():
v['path'] = '/'
return cookies
示例8: rewrite
# 需要导入模块: from Cookie import SimpleCookie [as 别名]
# 或者: from Cookie.SimpleCookie import iteritems [as 别名]
def rewrite(self, cookie_str, header='Set-Cookie'):
results = []
cookie = SimpleCookie()
try:
cookie.load(cookie_str)
except CookieError:
return results
for name, morsel in cookie.iteritems():
morsel = self.rewrite_cookie(name, morsel)
if morsel:
path = morsel.get('path')
if path:
inx = path.find(self.url_rewriter.rel_prefix)
if inx > 0:
morsel['path'] = path[inx:]
results.append((header, morsel.OutputString()))
return results
示例9: _parse_cookies
# 需要导入模块: from Cookie import SimpleCookie [as 别名]
# 或者: from Cookie.SimpleCookie import iteritems [as 别名]
def _parse_cookies(request):
cookie = Cookie(request["headers"].get("cookie"))
parsed = {}
for k, v in cookie.iteritems():
parsed[k] = v.value
return parsed
示例10: _parse_cookie
# 需要导入模块: from Cookie import SimpleCookie [as 别名]
# 或者: from Cookie.SimpleCookie import iteritems [as 别名]
def _parse_cookie(self):
try:
cookie = SimpleCookie(self._env.get('HTTP_COOKIE'))
except CookieError:
cookie = {}
self.cookie = dict((k, v.value) for k, v in cookie.iteritems())