This time has been trying to use Python in the SAE, the initial selection of the web.py framework as a development framework, but poor SAE on the poor data, a little problem basically can not solve, today solve a session in the session of the storage problem, In the SAE can not directly with the local file storage, as if the reason for the permissions, I now use is saved in MySQL, the effect is good. Hope to be of help to everyone. directly on the code.
Index.wsgi
#!/usr/bin/env python# coding:utf-8import osimport webimport saefrom config.url Import urlsfrom config import settings #是 No debug feature web.config.debug = false# app = web.application (URLs, Globals ()). Wsgifunc () # application = Sae.create_wsgi_app ( APP) #解决Session在SAE中的问题app = web.application (URLs, Globals ()) #将session保存在数据库中db = Settings.dbstore = Web.session.DBStore (DB, ' sessions ') #session = web.session.Session (app, store, initializer={' Access_token ': ' True '}) Session = Web.session.Session (app, store) Web.config._session = Session application = Sae.create_wsgi_app (App.wsgifunc ( )) url.py#!/usr/bin/env python# coding:utf-8 pre_fix = ' controllers. ' URLs = ('/', Pre_fix + ' Todo. Index ', '/todo/new ', Pre_fix + ' Todo. New ', '/todo/(\d+) ', Pre_fix + ' Todo. View ', '/todo/(\d+)/edit ', Pre_fix + ' Todo. Edit ', '/todo/(\d+)/delete ', Pre_fix + ' Todo. Delete ', '/todo/(\d+)/finish ', Pre_fix + ' Todo. Finish ', '/todo/login ', Pre_fix + ' login. Loginuser ', '/todo/checkuser ', pre_fix+ ' login.CheckUser ', '/todo/reset ', pre_fix+ ' todo.reset ', '/todo/saveupload ', ' mycontrollers.saveupload.SaveUpload ') Setting.py#!/usr/bin/env python# coding:utf-8import webimport sae.const# database Set db = Web.database (dbn= ' MySQL ', user= Sae.const.MYSQL_USER, Pw=sae.const.mysql_pass, Host=sae.const.mysql_host, port=3307, db=sae.const.mysql_db) # Template settings render = Web.template.render (' templates/', cache=false) config = web.storage (email= ' oooo@qq.com ', site_name = ' Task trace ', Site_desc = ', static = '/static ', ' web.template.template.globals[' config '] = configweb.template.template.globals[' Render '] = renderlogin.py#!/usr/bin/env python# coding:utf-8import webfrom config import settingsrender = Settings.rende Rdef Myloadhook (): Global Session session = Web.config._sessionclass Loginuser:def GET (self): return render. Loginuser () class Checkuser:def POST (self): #获取Session相关信息 myloadhook () #获取表单信息 i = web.input () Username = I.get (' txtUserName ', none) password=i.get (' txtUserPass ', none) #从全The local configuration file gets session session = Web.config._session if username = = ' chu888 ' and password = = ' chu888 ': Session.access_ token = ' true ' raise Web.seeother ('/') Else:session.access_token = ' false ' Raise Web.seeother ('/todo/lo Gin ')