コード例 #1
0
	def _update_cookies(self, response):
		cookies = Cookie()
		
		# Load any generated cookies.
		for cookie in response.headers.getall('Set-Cookie'):
			cookies.load(cookie)
		
		self.cookies.update({i.name.decode('ascii'): i.value.decode('ascii') for i in cookies.values()})
コード例 #2
0
ファイル: conftest.py プロジェクト: QPanWeb/FM_PY-pyramid
 def get_cookie(self, name, default=None):
     # webtest currently doesn't expose the unescaped cookie values
     # so we're using webob to parse them for us
     # see https://github.com/Pylons/webtest/issues/171
     cookie = Cookie(' '.join('%s=%s' % (c.name, c.value)
                              for c in self.cookiejar if c.name == name))
     return next(
         (m.value.decode('latin-1') for m in cookie.values()),
         default,
     )
コード例 #3
0
ファイル: response.py プロジェクト: startup-one/cogofly
 def unset_cookie(self, key, strict=True):
     """
     Unset a cookie with the given name (remove it from the
     response).
     """
     existing = self.headers.getall('Set-Cookie')
     if not existing and not strict:
         return
     cookies = Cookie()
     for header in existing:
         cookies.load(header)
     if key in cookies:
         del cookies[key]
         del self.headers['Set-Cookie']
         for m in list(cookies.values()):
             self.headerlist.append(('Set-Cookie', str(m)))
     elif strict:
         raise KeyError("No cookie has been set with the name %r" % key)
コード例 #4
0
ファイル: response.py プロジェクト: 404minds/quiz-forest
 def unset_cookie(self, key, strict=True):
     """
     Unset a cookie with the given name (remove it from the
     response).
     """
     existing = self.headers.getall('Set-Cookie')
     if not existing and not strict:
         return
     cookies = Cookie()
     for header in existing:
         cookies.load(header)
     if key in cookies:
         del cookies[key]
         del self.headers['Set-Cookie']
         for m in cookies.values():
             self.headerlist.append(('Set-Cookie', str(m)))
     elif strict:
         raise KeyError("No cookie has been set with the name %r" % key)
コード例 #5
0
ファイル: response.py プロジェクト: rylz/webob
 def unset_cookie(self, name, strict=True):
     """
     Unset a cookie with the given name (remove it from the
     response).
     """
     existing = self.headers.getall('Set-Cookie')
     if not existing and not strict:
         return
     cookies = Cookie()
     for header in existing:
         cookies.load(header)
     if isinstance(name, text_type):
         name = name.encode('utf8')
     if name in cookies:
         del cookies[name]
         del self.headers['Set-Cookie']
         for m in cookies.values():
             self.headerlist.append(('Set-Cookie', m.serialize()))
     elif strict:
         raise KeyError("No cookie has been set with the name %r" % name)
コード例 #6
0
 def unset_cookie(self, name, strict=True):
     """
     Unset a cookie with the given name (remove it from the
     response).
     """
     existing = self.headers.getall('Set-Cookie')
     if not existing and not strict:
         return
     cookies = Cookie()
     for header in existing:
         cookies.load(header)
     if isinstance(name, text_type):
         name = name.encode('utf8')
     if name in cookies:
         del cookies[name]
         del self.headers['Set-Cookie']
         for m in cookies.values():
             self.headerlist.append(('Set-Cookie', m.serialize()))
     elif strict:
         raise KeyError("No cookie has been set with the name %r" % name)
コード例 #7
0
ファイル: response.py プロジェクト: mvidner/webob
 def unset_cookie(self, key, strict=True):
     """
     Unset a cookie with the given name (remove it from the
     response).
     """
     existing = self.headers.getall("Set-Cookie")
     if not existing and not strict:
         return
     cookies = Cookie()
     for header in existing:
         cookies.load(header)
     if isinstance(key, text_type):
         key = key.encode("utf8")
     if key in cookies:
         del cookies[key]
         del self.headers["Set-Cookie"]
         for m in cookies.values():
             self.headerlist.append(("Set-Cookie", m.serialize()))
     elif strict:
         raise KeyError("No cookie has been set with the name %r" % key)