This article mainly Introduces web. solve the Session problem of py in SAE (using mysql storage). This article provides the implementation code directly. the code contains detailed comments, if you want to use Python in SAE, you can refer to this period of time. the py framework is used as a development framework. However, there is little information on the SAE, and a problem is basically not solved. Today, the Session storage problem is solved, in SAE, local file storage cannot be used directly. it seems to be the reason for permission. I am using mysql to save it, and the effect is good. I hope to help you. Code directly.
Index. wsgi
#! /Usr/bin/env python # coding: utf-8import osimport webimport saefrom config. url import urlsfrom config import settings # whether the web Debugging function is available. config. debug = False # app = web. application (urls, globals ()). wsgifunc () # application = sae. create_wsgi_app (app) # solve the problem of Session in SAE app = web. application (urls, globals () # save the session in the database db = settings. dbstore = web. session. DBStore (db, 'session') # session = web. session. ses Sion (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', '/ Do/reset ', pre_fix + 'Todo. reset','/todo/saveupload ', 'mycontrollers. saveupload. saveupload') setting. py #! /Usr/bin/env python # coding: utf-8import webimport sae. const # database configuration 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 setting render = web. template. render ('Templates/', cache = False) config = web. storage (email = 'Oooo @ qq.com