我让模板动态重新加载,但控制器代码没有;我必须杀死并重新启动该过程。下面列出的是我运行的代码;我将它作为python app.py
.
我有什么错误配置以及如何让代码动态重新加载?
if __name__ == '__main__':
# configuration settings
settings = {}
settings['reload_all'] = True
settings['debug_all'] = True
settings['mako.directories'] = os.path.join(here, 'templates')
#settings['db'] = os.path.join(here, 'tasks.db')
# session factory
session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
# configuration setup
config = Configurator(settings=settings, session_factory=session_factory)
# routes setup
#config.add_route('list', '/')
#config.add_route('new', '/new')
#config.add_route('close', '/close/{id}')
#config.add_route('hello', '/hello')
config.add_route('meta', '/m/{mid}')
# static view setup
config.add_static_view('static', os.path.join(here, 'static'))
# scan for @view_config and @subscriber decorators
connection = pymongo.Connection()
def add_db(request):
#db = config.registry.db[db_url.path[1:]]
#if db_url.username and db_url.password:
#db.authenticate(db_url.username, db_url.password)
db = connection["bricwall_pyramid"]["bricwall"]
return db
#def add_fs(request):
#return GridFS(request.db)
config.add_request_method(add_db, 'db', reify=True)
#config.add_request_method(add_fs, 'fs', reify=True)
config.scan()
# serve app
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()