Source code for cadrumo.adapters.persistence.profile.filing_history
"""Encrypted persistence adapter for application filing-history ports.Core types::class:`~cadrumo.adapters.persistence.storage.sql.secure_objects.SecureObjectRepository`,:class:`~cadrumo.core.classification.policies.SensitivityClass`."""from__future__importannotationsfromcollections.abcimportIteratorfromtypingimportClassVar,overridefrom....application.filing.history_modelsimportModeloHistoryfrom....application.filing.history_portsimport(FILING_HISTORY_NAMESPACE,FILING_HISTORY_SCHEMA_VERSION,FILING_HISTORY_SENSITIVITY,FilingHistoryPersistenceError,FilingHistoryRepositoryPort,)from....core.classification.policiesimportSensitivityClassfrom..storage.envelope.secure_bound_repositoryimportSecureBoundRepositoryfrom..storage.errorsimportStorageErrorfrom..storage.sql.secure_objectsimportSecureObjectRepository
[docs]classFilingHistoryRepositoryAdapter(SecureBoundRepository[ModeloHistory],FilingHistoryRepositoryPort,):"""Bind the application contract to the encrypted secure-object repository."""namespace:ClassVar[str]=FILING_HISTORY_NAMESPACEsensitivity:ClassVar[SensitivityClass]=FILING_HISTORY_SENSITIVITYschema_version:ClassVar[int]=FILING_HISTORY_SCHEMA_VERSIONpayload_type:ClassVar[type[ModeloHistory]]=ModeloHistorydef__init__(self,*,objects:SecureObjectRepository)->None:"""Bind an already-composed secure-object store; never resolve one here."""super().__init__(objects=objects)
@staticmethoddef_translate(operation:str,error:StorageError)->FilingHistoryPersistenceError:"""Translate storage-specific failures before they cross the port."""returnFilingHistoryPersistenceError(translated_message="application.filing.errors.persistence",context={"operation":operation,"adapter_error":type(error).__name__},)
[docs]@overridedefload(self,identifier:str)->ModeloHistory|None:"""Load one encrypted history and translate storage failures."""try:returnsuper().load(identifier)exceptStorageErroraserror:raiseself._translate("load",error)fromerror
[docs]@overridedefsave(self,payload:ModeloHistory)->None:"""Save one encrypted history and translate storage failures."""try:super().save(payload)exceptStorageErroraserror:raiseself._translate("save",error)fromerror
[docs]@overridedefdelete(self,identifier:str)->bool:"""Delete one encrypted history and translate storage failures."""try:returnsuper().delete(identifier)exceptStorageErroraserror:raiseself._translate("delete",error)fromerror
[docs]@overridedefiter_records(self)->Iterator[ModeloHistory]:"""Iterate encrypted histories and translate scan failures."""try:yield fromsuper().iter_records()exceptStorageErroraserror:raiseself._translate("iter_records",error)fromerror