Changeset ef964d8 in flexoentity for flexoentity/domain.py
- Timestamp:
- 11/27/25 18:12:23 (7 weeks ago)
- Branches:
- master
- Children:
- 4e11d58
- Parents:
- 9a50e0b
- File:
-
- 1 edited
-
flexoentity/domain.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
flexoentity/domain.py
r9a50e0b ref964d8 1 from uuid import UUID2 1 from dataclasses import dataclass 3 from flexoentity import FlexOID, FlexoEntity, EntityType 2 from flexoentity import FlexoEntity, EntityType 3 4 4 5 5 @dataclass … … 26 26 return self.domain_id 27 27 28 def _deserialize_content(self, content: dict): 29 self.fullname = content.get("fullname", "") 30 self.description = content.get("description", "") 31 self.classification = content.get("classification", "UNCLASSIFIED") 32 28 33 def _serialize_content(self): 29 34 return { … … 32 37 "classification": self.classification, 33 38 } 34 39 35 40 @classmethod 36 41 def from_dict(cls, data): 37 # Must have flexo_id38 if "flexo_id" not in data:39 raise ValueError("Domain serialization missing 'flexo_id'.")40 42 41 flexo_id = FlexOID(data["flexo_id"]) 42 43 obj = cls( 44 fullname=data.get("fullname", ""), 45 description=data.get("description", ""), 46 classification=data.get("classification", "UNCLASSIFIED"), 47 flexo_id=flexo_id, 48 _in_factory=True 49 ) 50 51 # Restore metadata 52 obj.origin = data.get("origin") 53 obj.fingerprint = data.get("fingerprint", "") 54 obj.originator_id = ( 55 UUID(data["originator_id"]) if data.get("originator_id") else None 56 ) 57 obj.owner_id = ( 58 UUID(data["owner_id"]) if data.get("owner_id") else None 59 ) 60 43 obj = super().from_dict(data) 44 content = data.get("content", {}) 45 obj._deserialize_content(content) 61 46 return obj
Note:
See TracChangeset
for help on using the changeset viewer.
