def __setitem__(self, key, value): obj = AbstractPriorModel.from_object(value) try: obj.id = getattr(self, str(key)).id except AttributeError: pass setattr(self, str(key), obj)
def __setattr__(self, key, value): if key.startswith("_"): super().__setattr__(key, value) else: try: super().__setattr__(key, AbstractPriorModel.from_object(value)) except AttributeError: pass
def add_dict_items(self, item_dict): for key, value in item_dict.items(): setattr(self, key, AbstractPriorModel.from_object(value))
def append(self, item): setattr(self, str(self.item_number), AbstractPriorModel.from_object(item)) self.item_number += 1