def remove_plugin_templates_path(path): global env tmpl_path = make_templates_from_plugin_path(path) if tmpl_path in template_path: template_path.remove(tmpl_path) # for webhooks TEMPLATE_PATH.remove(tmpl_path) # for webviews env = Environment(loader=FileSystemLoader(template_path)) # ditch and recreate a new templating environment
def remove_plugin_templates_path(path): global env tmpl_path = make_templates_from_plugin_path(path) if tmpl_path in template_path: template_path.remove(tmpl_path) # for webhooks TEMPLATE_PATH.remove(tmpl_path) # for webviews # Ditch and recreate a new templating environment env = Environment(loader=FileSystemLoader(template_path))
def setup_app(): root = os.path.dirname(os.path.abspath(__file__)) session_opts = { 'session.type': 'file', 'session.cookie_expires': 3600 * 10, 'session.data_dir': os.path.join(root, 'data/'), 'session.auto': True } app = Bottle() app = setup_routing(app) TEMPLATE_PATH.append(os.path.join(root, 'templates/')) TEMPLATE_PATH.remove('./views/') app = SessionMiddleware(app, session_opts) return app
#!/usr/bin/python from bottle import Bottle, TEMPLATE_PATH app = Bottle() TEMPLATE_PATH.append("./project/views/") TEMPLATE_PATH.remove("./views/") from project.controllers import *
#!/usr/bin/python from bottle import Bottle, TEMPLATE_PATH app = Bottle() TEMPLATE_PATH.append("./project/views/") TEMPLATE_PATH.remove("./views/") from project.controllers import *
from bottle import TEMPLATE_PATH from plugins.dbconnect import dbConnectPlunin ##模板路径 TEMPLATE_PATH.remove('./views/') TEMPLATE_PATH.append('template') # ##数据库 db_config={ 'db':'blog', 'table':'*', 'keyword':'db', 'host':'', 'port':3306, 'username':'******', 'password':'******', 'charset':'utf8', 'autocommit':True, 'pool_size':8, 'wait_timeout':30 } db=dbConnectPlunin(db_config)