forked from HugoPresents/post_bar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py.default
47 lines (41 loc) · 1.62 KB
/
index.py.default
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -- coding: utf8 --
import sys
import os
if sys.getdefaultencoding() != 'utf-8':
reload(sys)
sys.setdefaultencoding('utf-8')
#abspath = os.path.dirname(__file__)
#sys.path.append(abspath)
#os.chdir(abspath)
sys.path.append('/var/www/post_bar')
os.chdir('/var/www/post_bar')
import web
from config.config import *
from config.urls import *
from libraries import widget
from libraries import helper
from models.site_model import *
from models.user_model import *
from models.notify_model import *
#web.template.Template.globals['render'] = render
#web.template.Template.globals['site_title'] = site_title
web.template.Template.globals['widget'] = widget
web.template.Template.globals['site_options'] = site_model().get_options()
web.template.Template.globals['helper'] = helper
app = web.application(urls, globals(), autoreload = True)
if web.config.get('_session') is None:
#session = web.session.Session(app, web.session.DiskStore('sessions'), initializer={'user_id': None})
curdir = os.path.dirname(__file__)
session = web.session.Session(app, web.session.DiskStore(os.path.join(curdir,'sessions')), initializer={'user_id': None})
web.config._session = session
else:
session = web.config._session
app.add_processor(user_model().auth_cookie)
app.add_processor(notify_model().check)
# 如果这里不 不将 session 赋值给模板全局变量, 模板中将不能得到此变量
web.template.Template.globals['session'] = session
#web.template.Template.globals['site_url'] = 'http://post_bar.localhost'
application = app.wsgifunc()
#if __name__ == "__main__":
# app.run()
# 我擦,肿么出现合并死循环了!