Ejemplo n.º 1
0
class TestEnvAppConfig(dict):

    env_list = config_property('foo.list', list, lookup_env=True)
    env_dict = config_property('foo.dict', dict, lookup_env=True)
    env_list_recurse = config_property('foo.list_recurse', list,
                                       lookup_env=True)
    env_lookup = config_property('foo.bar', str, lookup_env=True)
    env_false = config_property('foo.qux', str, lookup_env=False)
    env_error = config_property('foo.quux', str, lookup_env=True)
    given_first = config_property('foo.quuz', str, lookup_env=True)
    parse = config_property('foo.parse', bool,
                            lookup_env=True,
                            parse_env=lambda x: x == 'True')
    empty_text = config_property('foo.empty', str, lookup_env=True)
    env_object = config_object_property('foo.obj', SampleInterface)
    recursiveobj = config_object_property('foo.recurse', SampleInterface,
                                          recurse=True)
    parse_object = config_object_property(
        'foo.parse',
        SampleInterface,
        parse_env=parse_foo,
        lookup_env=True
    )
    overlay_with_env = config_property(
        'foo.overlay_env', dict, lookup_env=True
    )
Ejemplo n.º 2
0
class App(WebConfiguration):
    """서버 애플리케이션입니다."""
    secret_key = config_property(
        'web.secret_key', str, '쿠키 암호화용 비밀키'
    )

    database_url = config_property(
        'database.url', str, '데이터베이스 연결용 문자열'
    )

    debug = config_property('web.debug', bool, default=True)

    @cached_property
    def database_engine(self) -> Engine:
        return create_engine(self.database_url)

    def create_session(self, bind: Optional[Engine] = None) -> Session:
        if bind is None:
            bind = self.database_engine
        return Session(bind=bind)
Ejemplo n.º 3
0
class TestConfig(dict):
    depth1_required = config_property('key', int)
    depth1_optional = config_property('key', int, default='')
    depth1_warn = config_property('key', int, default='', default_warning=True)
    depth1_default_func = config_property(
        'key', int,
        default_func=lambda self: self.depth1_optional
    )
    depth1_default_func_warn = config_property(
        'key', int,
        default_func=lambda self: self.depth1_optional,
        default_warning=True
    )
    depth2_required = config_property('section.key', str)
    depth2_optional = config_property('section.key', str, default=None)
    depth2_warn = config_property('section.key', str,
                                  default=None, default_warning=True)
    union = config_property('union', typing.Union[int, str])
Ejemplo n.º 4
0
class TestAppConfig(Configuration):
    database_url = config_property(
        'database.url', str,
        default='sqlite:///test_app.db', default_warning=True
    )
Ejemplo n.º 5
0
class EnumTestConfig(dict):
    enum = config_property('enum', Enum1, default=Enum1.apple)
    enum_union = config_property('enum_union', typing.Union[Enum1, Enum2, str])