# Path: kokoropy/model.py
# class BaseConfig(object):
#     '''
#     BaseConfig class, should be inherited in model's _config to ensure there are just
#     one engine, session, and metadata across models
#     '''
#     __property = {}
# 
#     def __init__( self, connection_string, *args, **kwargs):
#         engine = create_engine(connection_string, *args, **kwargs)
#         engine.raw_connection().connection.text_factory = str
#         session = scoped_session(sessionmaker(bind=self.engine))
#         metadata = MetaData()
#         metadata.bind = engine
#         self.set_property('engine', engine)
#         self.set_property('session', session)
#         self.set_property('metadata', metadata)
# 
#     @property
#     def engine(self):
#         return self.get_property('engine')
# 
#     @property
#     def session(self):
#         return self.get_property('session')
# 
#     @property
#     def metadata(self):
#         return self.get_property('metadata')
# 
#     @declared_attr
#     def application_name(self):
#         path = sys.modules[self.__module__].__file__
#         return os.path.dirname(os.path.dirname(path)).split('/')[-1]
#     
#     def set_property(self, key, value):
#         key = self.application_name + key
#         if key not in BaseConfig.__property:
#             BaseConfig.__property[key] = value
#     
#     def get_property(self, key):
#         key = self.application_name + key
#         if key in BaseConfig.__property:
#             return BaseConfig.__property[key]


from kokoropy.model import BaseConfig
from ..configs.db import connection_string

# create Config class to ensure there is only one engine, session, and metadata accross models
class Config(BaseConfig):
    pass
config = Config(connection_string, echo=False)

# use these things in your models
engine   = config.engine
session  = config.session

# Path: kokoropy/model.py
# class BaseConfig(object):
#     '''
#     BaseConfig class, should be inherited in model's _config to ensure there are just
#     one engine, session, and metadata across models
#     '''
#     __property = {}
# 
#     def __init__( self, connection_string, *args, **kwargs):
#         engine = create_engine(connection_string, *args, **kwargs)
#         engine.raw_connection().connection.text_factory = str
#         session = scoped_session(sessionmaker(bind=self.engine))
#         metadata = MetaData()
#         metadata.bind = engine
#         self.set_property('engine', engine)
#         self.set_property('session', session)
#         self.set_property('metadata', metadata)
# 
#     @property
#     def engine(self):
#         return self.get_property('engine')
# 
#     @property
#     def session(self):
#         return self.get_property('session')
# 
#     @property
#     def metadata(self):
#         return self.get_property('metadata')
# 
#     @declared_attr
#     def application_name(self):
#         path = sys.modules[self.__module__].__file__
#         return os.path.dirname(os.path.dirname(path)).split('/')[-1]
#     
#     def set_property(self, key, value):
#         key = self.application_name + key
#         if key not in BaseConfig.__property:
#             BaseConfig.__property[key] = value
#     
#     def get_property(self, key):
#         key = self.application_name + key
#         if key in BaseConfig.__property:
#             return BaseConfig.__property[key]


# Path: kokoropy/scaffolding/scaffold_application/models/_config.py
from kokoropy.model import BaseConfig
from ..configs.db import connection_string


# create Config class to ensure there is only one engine, session, and metadata accross models
class Config(BaseConfig):
    pass
config = Config(connection_string, echo=False)

# use these things in your models
engine   = config.engine
session  = config.session

metadata = config.metadata