Python 获取当前会话返回无

Python 获取当前会话返回无,python,google-app-engine,session,Python,Google App Engine,Session,我已经用了一段时间了,效果很好。它简单快捷 但今天我启动了一个新项目(GAE v1.3.7),但无法让它运行,get\u current\u session()只返回None 我已将代码拆分为一个新项目,该项目仅使用gaesessions: from google.appengine.ext import webapp from google.appengine.ext.webapp import util from google.appengine.ext.webapp import temp

我已经用了一段时间了,效果很好。它简单快捷

但今天我启动了一个新项目(GAE v1.3.7),但无法让它运行,
get\u current\u session()
只返回
None

我已将代码拆分为一个新项目,该项目仅使用gaesessions:

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template
from gaesessions import get_current_session
import logging

class MainHandler(webapp.RequestHandler):
    def get(self):
        session = get_current_session()
        logging.info(session)
        path = os.path.join(os.path.dirname(__file__), 'index.html')
        self.response.out.write(template.render(path, { }))
而在日志中,它只是说
None

奇怪的是,其他解决方案仍然有效。(我猜这是因为会话的db.Model已经存在)。测试了我在那里使用的两个版本,并下载了最新版本(1.04)

我已经看过了《性别歧视》这本书,有点道理,它不返回任何内容:

_current_session = None
def get_current_session():
    """Returns the session associated with the current request."""
    return _current_session
我找不到调用Session类的任何地方,但这可能是我的python技能


有人使用gaesession并知道发生了什么吗?

我想你错过了一些东西

无论如何,如果向下滚动源代码,您也会注意到这部分代码实际上将
\u当前会话
变量定值

def __call__(self, environ, start_response):
        # initialize a session for the current user
        global _current_session
        _current_session = Session(lifetime=self.lifetime, no_datastore=self.no_datastore, cookie_only_threshold=self.cookie_only_thresh, cookie_key=self.cookie_key)

您完全正确,忘记在appengine\u配置中添加SessionMiddleware!