Beispiel #1
0
 def delete(self):
     """
     Deletes the entity from the data store
     :return:
     """
     self.id = uuid4()
     DataStore.remove_instance(self)
Beispiel #2
0
 def save(self):
     """
     Generates the id for the entity if not present and save it to the data store
     :return:
     """
     if not self.id:
         self.id = uuid4()
     DataStore.add_instance(self)
Beispiel #3
0
 def __init__(self, data_filename):
     try:
         self._portfolio = PortfolioMgr(DataStore(data_filename),
                                        ApiClient())
     except ValueError:
         raise
     self._app_date = date.today()
Beispiel #4
0
 def get(cls, _id):
     """
     Can be used to fetch a particular entity by id from the data store
     :param _id:
     :return:
     """
     return DataStore.get_instance(cls, _id)
Beispiel #5
0
 def __init__(self, data_filename):
     self._portfolio = PortfolioMgr(DataStore(data_filename), ApiClient())
     self._app_date = date.today()
Beispiel #6
0
from . import *

# automatically registers all the entities to data store

from app import entities
from app.entities.base import BaseEntity
from types import ModuleType
from app.datastore import DataStore

for name, cls in entities.__dict__.items():
    if isinstance(cls, ModuleType) and name != 'app.entities.base':
        for inner_name, inner_cls in cls.__dict__.items():
            try:
                if issubclass(inner_cls,
                              BaseEntity) and inner_name != 'BaseEntity':
                    DataStore.register_entity(inner_cls)
            except TypeError as e:
                pass
Beispiel #7
0
 def get_all(cls):
     """
     Returns all the instances of a particular entity
     :return:
     """
     return DataStore.get_all_instance(cls)