我一直在努力将我们的一个应用程序转换为线程安全的。在本地开发应用服务器上进行测试时,一切都按预期工作。但是,在部署应用程序时,似乎没有正确写入 Cookie?
在日志中有一个没有堆栈跟踪的错误:
2012-11-27 16:14:16.879 Set-Cookie: idd_SRP=Uyd7InRpbnlJZCI6ICJXNFdYQ1ZITSJ9JwpwMAou.Q6vNs9vGR-rmg0FkAa_P1PGBD94; expires=Wed, 28-Nov-2012 23:59:59 GMT; Path=/
这是有问题的代码块:
# area of the code the emits the cookie
cookie = Cookie.SimpleCookie()
if not domain:
domain = self.__domain
self.__updateCookie(cookie, expires=expires, domain=domain)
self.__updateSessionCookie(cookie, domain=domain)
print cookie.output()
Cookie 辅助方法:
def __updateCookie(self, cookie, expires=None, domain=None):
"""
Takes a Cookie.SessionCookie instance an updates it with all of the
private persistent cookie data, expiry and domain.
@param cookie: a Cookie.SimpleCookie instance
@param expires: a datetime.datetime instance to use for expiry
@param domain: a string to use for the cookie domain
"""
cookieValue = AccountCookieManager.CookieHelper.toString(self.cookie)
cookieName = str(AccountCookieManager.COOKIE_KEY % self.partner.pid)
cookie[cookieName] = cookieValue
cookie[cookieName]['path'] = '/'
cookie[cookieName]['domain'] = domain
if not expires:
# set the expiry date to 1 day from now
expires = datetime.date.today() + datetime.timedelta(days = 1)
expiryDate = expires.strftime("%a, %d-%b-%Y 23:59:59 GMT")
cookie[cookieName]['expires'] = expiryDate
def __updateSessionCookie(self, cookie, domain=None):
"""
Takes a Cookie.SessionCookie instance an updates it with all of the
private session cookie data and domain.
@param cookie: a Cookie.SimpleCookie instance
@param expires: a datetime.datetime instance to use for expiry
@param domain: a string to use for the cookie domain
"""
cookieValue = AccountCookieManager.CookieHelper.toString(self.sessionCookie)
cookieName = str(AccountCookieManager.SESSION_COOKIE_KEY % self.partner.pid)
cookie[cookieName] = cookieValue
cookie[cookieName]['path'] = '/'
cookie[cookieName]['domain'] = domain
同样,正在使用的库是:
- 蟒蛇 2.7
- 姜戈 1.2
关于我可以尝试什么的任何建议?