# -*- coding: utf-8 -*-

"""
Здесь описывается класс объектов, которые работыют с базой.
"""

from stocks3.core.config import Configurable
from stocks3.core.config import JSONConfigurable


# class WithDBConfiguration(Configurable):
#     # def __init__(self, tree, node, **kwargs):
#     #     self.connectionstring = None
#     #     Configurable.__init__(self, tree, node, **kwargs)
#
#     def makeConfig(self):
#         # print('makeConfig in WithDBConfiguration')
#         # self.connectionstring = self.readString("db", "connectionstring")
#         return self
#
#     def get_dbinfo(self):
#         return self.connectionstring

class WithDBConfiguration(JSONConfigurable):
    def __init__(self, tree, node, configfile="config/config.json"):
        self.connectionstring = ''
        JSONConfigurable.__init__(self, configfile)
        self.connectionstring = self.read_item(["db", "connectionstring"])

    def makeConfig(self):
        return self.make_config()

    def make_config(self):
        return self

    def get_dbinfo(self):
        return self.connectionstring
