示例#1
0
文件: __init__.py 项目: ccfr32/www
    def __init__(self):
        settings = setting_from_object(config)
        
        handlers = [
            url(r"/static/download/(.*)", tornado.web.StaticFileHandler, dict(path=settings['upload_path']), name='upload_path'),       
            url(r"/static/js/(.+)", tornado.web.StaticFileHandler, dict(path=settings['js_path']), name='js_path'),
            url(r"/static/css/(.+)", tornado.web.StaticFileHandler, dict(path=settings['css_path']), name='css_path'),
            url(r"/static/img/(.+)", tornado.web.StaticFileHandler, dict(path=settings['img_path']), name='img_path'),
            url(r"/static/fonts/(.+)", tornado.web.StaticFileHandler, dict(path=settings['fonts_path']), name='fonts_path'),
       
        ]
        handlers += Route.routes()
        handlers.append((r"/(.*)", ErrorHandler))  # Custom 404 ErrorHandler

        # static_path 的设置和StaticFileHandler,以及static_url函数有关
        # settings['static_path'] = settings['project_path']
        settings.update(dict(
            gzip = True,
            ui_modules = uimodules,
            autoescape = None
        ))
        
        if 'default_locale' in settings:
            tornado.locale.load_gettext_translations(
                os.path.join(os.path.dirname(__file__), 'translations'), 'messages')

        tornado.web.Application.__init__(self, handlers, **settings)
        
        self.forms = create_forms()
        pool = redis.ConnectionPool(host=settings['redis_host'], port=settings['redis_port'], db=settings['redis_db'])
        self.redis = redis.Redis(connection_pool=pool)
        self.session_store = RedisSessionStore(self.redis)
        
        configure_signals(db.sender)
示例#2
0
文件: __init__.py 项目: winkidney/app
    def __init__(self):
        settings = setting_from_object(config)
        handlers = [
            # other handlers...
            url(r"/theme/static/(.+)",
                tornado.web.StaticFileHandler,
                dict(path=settings['theme_static_path']),
                name='theme_static'),
            url(r"/upload/(.+)",
                tornado.web.StaticFileHandler,
                dict(path=settings['upload_path']),
                name='upload_path')
        ] + Route.routes()

        # Custom 404 ErrorHandler
        handlers.append((r"/(.*)", ErrorHandler))

        settings.update(dict(ui_modules=uimodules, autoescape=None))

        if 'default_locale' in settings:
            tornado.locale.load_gettext_translations(
                os.path.join(os.path.dirname(__file__), 'translations'),
                'messages')

        tornado.web.Application.__init__(self, handlers, **settings)

        self.forms = create_forms()
        pool = redis.ConnectionPool(host=settings['redis_host'],
                                    port=settings['redis_port'],
                                    db=settings['redis_db'])
        self.redis = redis.Redis(connection_pool=pool)
        self.session_store = RedisSessionStore(self.redis)

        configure_signals(db.sender)
示例#3
0
    def __init__(self):
        settings = setting_from_object(config)
        handlers = [
            # other handlers...
            url(r"/theme/(.+)", tornado.web.StaticFileHandler, dict(path=settings['theme_path']), name='theme_path'),
            url(r"/upload/(.+)", tornado.web.StaticFileHandler, dict(path=settings['upload_path']), name='upload_path')
        ] + Route.routes()
        
        # Custom 404 ErrorHandler
        handlers.append((r"/(.*)", ErrorHandler)) 
        
        settings.update(dict(
            ui_modules = uimodules,
            autoescape = None
        ))
        
        if 'default_locale' in settings:
            tornado.locale.load_gettext_translations(
                os.path.join(os.path.dirname(__file__), 'translations'), 'messages')

        tornado.web.Application.__init__(self, handlers, **settings)
        
        self.forms = create_forms()
        self.redis = redis.StrictRedis()
        self.session_store = RedisSessionStore(self.redis)
        
        configure_signals(db.sender)