简体   繁体   English

不能在谷歌appengine的实时实例上写cookie

[英]Cant write cookies on live instance of google appengine

I have been working towards converting one of our applications to be threadsafe. 我一直在努力将我们的一个应用程序转换为线程安全。 When testing on the local dev app server everything is working as expected. 在本地开发应用服务器上进行测试时,一切都按预期工作。 However, upon deployment of the application it seems that Cookies are not being written correctly? 但是,在部署应用程序时,似乎没有正确编写Cookie?

Within the logs there is an error with no stack trace: 在日志中有一个没有堆栈跟踪的错误:

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=/ 

Here is the block of code in question: 这是有问题的代码块:

# 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 helper methods: 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

Again, the libraries in use are: 同样,使用的库是:

  • Python 2.7 Python 2.7
  • Django 1.2 Django 1.2

Any suggestion on what I can try? 关于我可以尝试什么的任何建议?

I see the code for creating the cookie, but do you actually attach it to the response anywhere? 我看到了创建cookie的代码,但实际上你是否将它附加到响应中?

You should have a response.set_cookie() somewhere. 你应该在某处有一个response.set_cookie()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 什么是 Google AppEngine 实例? - What is a Google AppEngine Instance? 谷歌云控制台(Appengine)中的 Mysql 实例崩溃 - Mysql instance in google cloud console (Appengine) crashed Google AppEngine将所有请求发送到同一实例 - Google AppEngine sending all requests to same instance Google AppEngine服务器实例时钟同步 - Google AppEngine server instance clock synchronization 如何区分Google AppEngine上的本地部署和实时部署 - How to differentiate between local deployment and live deployment on Google AppEngine AppEngine端点HTTP Cookie - AppEngine Endpoints HTTP Cookies 如何在Google Appengine中从实体列表下钻到实体实例? - How to drill down from entity list to entity instance in Google Appengine? 将 Google AppEngine Django 与 SQL 第二代实例连接时出错? - Error connecting Google AppEngine Django with SQL 2nd generation instance? 如何使用python和Google AppEngine编写或创建(当不存在时)文件 - how to write or create (when no exist) a file using python and Google AppEngine Google App Engine:com.google.appengine.api.labs.modules.ModulesException:此实例没有有效的实例ID - Google App Engine: com.google.appengine.api.labs.modules.ModulesException: No valid instance id for this instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM