def get(self, key, db, delete=False): if delete: self.delete(key, db) tbl = getTbl(db, Computed.tblKey) item = tbl.find_one({KEY: key}) or getBigData(key, db) if item is None: value = self.getFunc(key)(db) saveBigItem(key, value, db, Computed.tblKey) item = { VALUE_KEY : value } return getIfKey(item, VALUE_KEY, item)
def __init__(self, item, db): self.db = db self.item = item self.dbId = getIfKey(item, MONGO_ID_KEY)