我在想 Pylons 的一个版本是不同的,但我找不到一种简单的方法来判断我正在运行哪些版本。在第一个示例中,我相当肯定它是 0.9.7 及更高版本,使用 webob 设置 cookie。此环境将 @ 符号设置为 \100。正如您在其他环境中看到的那样,执行完全相同的操作会正确设置值。如果您需要更多信息,请告诉我任何帮助,我们将不胜感激。
较新版本的 Pylons(我认为)错误地设置了值
response.set_cookie('email', 'user@domain.com', max_age=3600)
response.headers
ResponseHeaders([('Content-Type', 'text/html; charset=utf-8'), ('Content-Length','0'),
('Pragma', 'no-cache'), ('Cache-Control', 'no-cache'), ('Set-Cookie',
'email="user\\100domain.com"; expires="Fri, 03-Jun-2011 21:07:07 GMT"; Max-Age=3600; Path=/')])
测试环境正常/预期工作
response.set_cookie('email', 'user@domain.com', max_age=3600)
response.headers
HeaderDict([('Content-Type', 'text/html; charset=utf-8'), ('Content-Length', '0'),
('Pragma', 'no-cache'), ('Cache-Control', 'no-cache'), ('Set-Cookie',
'email=user@domain.com; expires="Fri, 03-Jun-2011 21:07:35 GMT"; Max-Age=3600; Path=/')])