def deconstruct(self, entity: Entity) -> Dto:
     """
     Defines a way to deconstruct (aka serialize) entity object into simple values.
     Simple deconstruction may just extract values from fields.
     Complex cases may need to use another factory to deconstruct objects of dependent types.
     """
     data = asdict(entity)
     if self.mapped_fields:
         data = {
             field: value
             for field, value in data.items() if field in self.mapped_fields
         }
     dto = Dto(data)
     dto.__id__ = entity.id
     return dto
Esempio n. 2
0
 def dto(self, data):
     dto = Dto(data)
     dto.__id__ = 17
     return dto
Esempio n. 3
0
 def dto(self, data):
     dto = Dto(data)
     dto.__id__ = 17
     return dto
 def insert(self, **kwargs) -> Id:
     id_ = self._get_id()
     dto = Dto(kwargs)
     dto.__id__ = id_
     self._register[id_] = dto
     return id_
Esempio n. 5
0
File: dao.py Progetto: lhaze/dharma
 def insert(self, **kwargs) -> Id:
     id_ = self._get_id()
     dto = Dto(kwargs)
     dto.__id__ = id_
     self._register[id_] = dto
     return id_