示例#1
0
def test_config_dict():
    conf = Config({'A': 1, 'B': 2}, C=3)
    assert len(conf) == 3

    # conf = Config.from_module(config_module)
    # assert "debug" in conf and "DEBUG" in conf and "DeBUg" in conf
    # conf['UPPER_KEY'] = 'UPPER_VALUE'
    # assert conf.get('upper_key') == 'UPPER_VALUE'

    conf = Config({'t_1': 1, 't_2': 2, 'x_3': 3, 'x_t': 4})
    assert conf.filter('T')._dict == {'2': 2, '1': 1}
示例#2
0
文件: web.py 项目: kzinglzy/zest
    def __init__(self, name=None, router=None, config=None, **more_config):
        self.name = name
        self.router = router or Router()
        self.config = Config.from_module(config or default_config)
        self.config.update(**more_config)

        self.root_path = self.find_root_path(self.name)
        self.set_config('root_path', self.root_path)
        self.static_folder = self.get_config('static_folder', '').strip('/\\')
        self.static_path = abspath(join(self.root_path, self.static_folder))

        self.hooks = {}  # TODO
        self.error_handler = {}

        self.register_template(self.get_config('template_engine',
                                               self.default_template))
        global G_ROUTER
        G_ROUTER = self.router