from ftest_common.logger import logger class Database(object): _instance = None db = {} # { "user": [{name: foo..}{..}{..}] } def __new__(cls): if cls._instance is None: logger.info("Creating the store") cls._instance = super(Database, cls).__new__(cls) return cls._instance def get_user(self, username): for u in self.db["users"]: print(u) if u["username"] == username: return u return None def add_user(self, username): if "users" not in self.db: self.db["users"] = [] self.db["users"].append({"username": username})