Exemple #1
0
class ZephyrApp(zephyr.breeze.Application):

    def __init__(self, config):
        self.config = config
        template_loader = self.boot_template()
        self.boot_database()
        
        self.autoload = AutoLoader()
        self.autoload.autoload()

        settings = dict(
            static_path=config.get("asset.path", os.path.join(os.path.dirname(__file__), "asset")),
            static_url_prefix=config.get("asset.url_prefix", "/assets/"),
            template_loader=template_loader,
            debug=self.config.get("debug", False),
            cookie_secret=self.config.get("secert_key", None)
        )
        zephyr.breeze.Application.__init__(
            self, self.autoload.routes, **settings)

        self.hooks.attach("on_start_request", zephyr.hooks.on_load_session)
        self.error_page(404, zephyr.hooks.on_not_found)

    def boot_template(self):
        template_loader = Jinja2Loader(
            os.path.join(os.path.dirname(__file__), "template"),
            self.config.get("jinja2.cache_path"),
            self.config.get("jinja2.cache_size", -1),
            auto_reload=self.config.get("jinja2.auto_reload", False))

        from zephyr import lang
        from zephyr.lang import text
        from zephyr.helper import categories, menus, site
        from zephyr.util import markdown

        lang.setup(self.config.get('language', 'en_GB'))

        template_loader.env.globals.update(__=text)
        template_loader.env.globals.update(site_categories=categories, menus=menus)
        template_loader.env.globals.update(site=site, enumerate=enumerate)

        template_loader.env.filters['markdown'] = markdown
        return template_loader

    def boot_database(self):
        db.setup(self.config.get('db'))
        pedis.setup(**self.config.get('redis'))
Exemple #2
0
class ZephyrApp(zephyr.breeze.Application):
    def __init__(self, config):
        self.config = config
        template_loader = self.boot_template()
        self.boot_database()

        self.autoload = AutoLoader()
        self.autoload.autoload()

        settings = dict(static_path=config.get(
            "asset.path", os.path.join(os.path.dirname(__file__), "asset")),
                        static_url_prefix=config.get("asset.url_prefix",
                                                     "/assets/"),
                        template_loader=template_loader,
                        debug=self.config.get("debug", False),
                        cookie_secret=self.config.get("secert_key", None))
        zephyr.breeze.Application.__init__(self, self.autoload.routes,
                                           **settings)

        self.hooks.attach("on_start_request", zephyr.hooks.on_load_session)
        self.error_page(404, zephyr.hooks.on_not_found)

    def boot_template(self):
        template_loader = Jinja2Loader(
            os.path.join(os.path.dirname(__file__), "template"),
            self.config.get("jinja2.cache_path"),
            self.config.get("jinja2.cache_size", -1),
            auto_reload=self.config.get("jinja2.auto_reload", False))

        from zephyr import lang
        from zephyr.lang import text
        from zephyr.helper import categories, menus, site
        from zephyr.util import markdown

        lang.setup(self.config.get('language', 'en_GB'))

        template_loader.env.globals.update(__=text)
        template_loader.env.globals.update(site_categories=categories,
                                           menus=menus)
        template_loader.env.globals.update(site=site, enumerate=enumerate)

        template_loader.env.filters['markdown'] = markdown
        return template_loader

    def boot_database(self):
        db.setup(self.config.get('db'))
        pedis.setup(**self.config.get('redis'))
Exemple #3
0
    def __init__(self, config):
        self.config = config
        template_loader = self.boot_template()
        self.boot_database()

        self.autoload = AutoLoader()
        self.autoload.autoload()

        settings = dict(static_path=config.get(
            "asset.path", os.path.join(os.path.dirname(__file__), "asset")),
                        static_url_prefix=config.get("asset.url_prefix",
                                                     "/assets/"),
                        template_loader=template_loader,
                        debug=self.config.get("debug", False),
                        cookie_secret=self.config.get("secert_key", None))
        zephyr.breeze.Application.__init__(self, self.autoload.routes,
                                           **settings)

        self.hooks.attach("on_start_request", zephyr.hooks.on_load_session)
        self.error_page(404, zephyr.hooks.on_not_found)
Exemple #4
0
    def __init__(self, config):
        self.config = config
        template_loader = self.boot_template()
        self.boot_database()
        
        self.autoload = AutoLoader()
        self.autoload.autoload()

        settings = dict(
            static_path=config.get("asset.path", os.path.join(os.path.dirname(__file__), "asset")),
            static_url_prefix=config.get("asset.url_prefix", "/assets/"),
            template_loader=template_loader,
            debug=self.config.get("debug", False),
            cookie_secret=self.config.get("secert_key", None)
        )
        zephyr.breeze.Application.__init__(
            self, self.autoload.routes, **settings)

        self.hooks.attach("on_start_request", zephyr.hooks.on_load_session)
        self.error_page(404, zephyr.hooks.on_not_found)