本文整理汇总了Python中tornado.web.Application.meta方法的典型用法代码示例。如果您正苦于以下问题:Python Application.meta方法的具体用法?Python Application.meta怎么用?Python Application.meta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.web.Application
的用法示例。
在下文中一共展示了Application.meta方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_app
# 需要导入模块: from tornado.web import Application [as 别名]
# 或者: from tornado.web.Application import meta [as 别名]
def make_app(**settings):
cwd = os.getcwd()
TORNADO_CONFIG.update(settings)
app_settings = DotDict(APP_CONFIG)
# setup the logging configuration
logging.config.dictConfigClass(app_settings.logging).configure()
logger.info('cwd, ' + cwd)
logger.info('creating application')
# determine where our flat assets are stored
static_path = os.path.join(cwd, 'static')
template_path = os.path.join(cwd, 'templates')
TORNADO_CONFIG['static_path'] = settings.get('static_path', static_path)
TORNADO_CONFIG['template_path'] = settings.get('template_path', template_path)
# set up our routing configuration
app = Application([
# hard routes
url(r'/feed.atom', AtomFeedHandler),
# soft routes
url(r'/login', LoginHandler),
url(r'/admin/create', AdminCreateHandler),
url(r'/search', DynamicSearchHandler),
url(r'/search/([a-z0-9_]+)/([a-zA-Z0-9\+\-_\%]+)(\.atom)?', StaticSearchHandler),
url(r'/blog/([a-zA-Z0-9\-_]+)\.html', OldBlogHandler),
url(r'/blog/([a-z]+)/(\d+)/(\d+)/(.*)/(\d+)', BlogHandler),
# catch-all routes
url(r'/static/(.*)', StaticFileHandler, {'path': static_path}),
url(r'/media/(.*)', StaticFileHandler, {'path': app_settings.media}),
url(r'/(.*\.(txt|ico))', StaticFileHandler, {'path': static_path}),
url(r'/', IndexHandler),
url(r'/(.*)', ErrorHandler)
], **TORNADO_CONFIG)
logger.info('finished setting up HTTP routes')
# storage location for singletons and factory methods
app.meta = DotDict()
app.meta.seo = SEO_VALUES
# ~~ config Search
app.meta.search_index = obtain_index(
WHOOSH.get('location'), SowingSchema, WHOOSH.get('index_name'))
logger.info('finished binding to Whoosh index')
# ~~ private settings
private_settings = app_settings.pop('private_settings', {})
# bootstrap the private settings into the meta-object accessible
# in the BaseHandler webRequest class
app.meta.private = private_settings
# ~~ authentication
auth = private_settings.get('auth', {})
username, password = auth.get('username', None), auth.get('password', None)
app.meta.auth_token = auth.get('token', None)
app.meta.username_combo = (username, password,)
logger.info('finished configuring authentication')
# callback settings for launching the server
app.meta.settings = app_settings
return app, app_settings