当前位置: 首页>>代码示例>>Python>>正文


Python Application.meta方法代码示例

本文整理汇总了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
开发者ID:blakev,项目名称:sowing-seasons,代码行数:71,代码来源:__init__.py


注:本文中的tornado.web.Application.meta方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。