This is really not true. I have load my models before run wsgi script handler. My moels desined in separate files.
As we can see in backtrace - we have error because we restore data in session on creating wsgi handler.
In code below we have:
1) on first page load we:
a) initial wsgi handler;
b) import User model (we can load also other models from other applications, but we don't kwon about all models and can't hardcode imports)
c) get user and store object in session
2) on second page load we:
a) have "not implemented model" error because session don't know about User model. This model dinamically loaded AFTER initialization of wsgi handler
Try this code:
# file main.py - enter point for all user requests
from google.appengine.ext import webapp
from gaesessions import get_current_session
class Application(webapp.RequestHandler):
def __init__(self):
self.session = get_current_session()
from models import User
def get(self):
# set user to session (only once)
if "user" not in self.session:
print self.session["user"]
if __name__ == "__main__":
application = webapp.WSGIApplication([('/.*', Application)])
run_wsgi_app(application)
SOLUTION: we need restore session data not on wsgi handler run, but ON FIRST dictionary lookup (add ne value or get value from session).
CURRENTLY we have loaded session data on wsgi handler initialization - but this is not good.