Exemple #1
0
    def bootstrap_setting(self):
        config = self.load_config()
        if not config:
            raise Exception("Load App Setting failed")
        self.app.config.from_object(config)

        if self.options.debug:
            self.app.config["DEBUG"] = True
            self.app.debug = True

        if self.options.host is not None:
            self.app.config["HOST"] = self.options.host

        if self.options.port is not None:
            self.app.config["PORT"] = self.options.port

        from white.ext import session

        session.app = self.app
        session.init_app(self.app)

        from white import lang
        from white.lang import text
        from white.flash import flash
        from white.helper import categories, menus, site
        from white.ext import markdown

        lang.setup(self.app.config.get("LANGUAGE", "en_GB"))

        self.app.jinja_env.globals.update(__=text)
        self.app.jinja_env.globals.update(flash=flash, site_categories=categories, menus=menus)
        self.app.jinja_env.globals.update(site=site, enumerate=enumerate)

        self.app.jinja_env.filters["markdown"] = markdown.convert
Exemple #2
0
    def bootstrap_setting(self):
        from white.setting import Config
        self.app.config.from_object(Config)
        config = self.load_config()

        if not config:
            raise Exception("Load App Setting failed")
        self.app.config.update(config)

        if self.options.debug:
            self.app.config['DEBUG'] = True
            self.app.debug = True

        if self.options.host is not None:
            self.app.config['HOST'] = self.options.host

        if self.options.port is not None:
            self.app.config['PORT'] = self.options.port

        from white.ext import session
        if self.app.config['SESSION_TYPE'] == 'redis':
            import redis
            import datetime
            self.app.config['SESSION_REDIS'] = redis.Redis(
                host=self.app.config['REDIS_HOST'])
            self.app.config['PERMANENT_SESSION_LIFETIME'] = datetime.timedelta(
                self.app.config.get('PERMANENT_SESSION_LIFETIME', 60))
        session.app = self.app
        session.init_app(self.app)

        from white import lang
        from white.lang import text
        from white.flash import flash
        from white.helper import categories, menus, site
        from white.ext import markdown
        lang.setup(self.app.config.get('LANGUAGE', 'en_GB'))

        # set static folder
        self.app.static_folder = self.app.config.get("STATIC_FOLDER", 'asset')
        self.app.jinja_env.globals.update(__=text)
        self.app.jinja_env.globals.update(flash=flash,
                                          site_categories=categories,
                                          menus=menus)
        self.app.jinja_env.globals.update(site=site, enumerate=enumerate)

        self.app.jinja_env.filters['markdown'] = markdown.convert
Exemple #3
0
    def bootstrap_setting(self):
        from white.setting import Config
        self.app.config.from_object(Config)
        config = self.load_config()

        if not config:
            raise Exception("Load App Setting failed")
        self.app.config.update(config)

        if self.options.debug:
            self.app.config['DEBUG'] = True
            self.app.debug = True

        if self.options.host is not None:
            self.app.config['HOST'] = self.options.host

        if self.options.port is not None:
            self.app.config['PORT'] = self.options.port

        from white.ext import session
        if self.app.config['SESSION_TYPE'] == 'redis':
            import redis
            import datetime
            self.app.config['SESSION_REDIS'] = redis.Redis(host=self.app.config['REDIS_HOST'])
            self.app.config['PERMANENT_SESSION_LIFETIME'] = datetime.timedelta(self.app.config.get('PERMANENT_SESSION_LIFETIME', 60))
        session.app = self.app
        session.init_app(self.app)

        from white import lang
        from white.lang import text
        from white.flash import flash
        from white.helper import categories, menus, site
        from white.ext import markdown
        lang.setup(self.app.config.get('LANGUAGE', 'en_GB'))

        # set static folder
        self.app.static_folder = self.app.config.get("STATIC_FOLDER", 'asset')
        self.app.jinja_env.globals.update(__=text)
        self.app.jinja_env.globals.update(
            flash=flash, site_categories=categories, menus=menus)
        self.app.jinja_env.globals.update(site=site, enumerate=enumerate)

        self.app.jinja_env.filters['markdown'] = markdown.convert