"""hooks to handle attributes mapped to a custom storage"""fromcubicweb.server.hookimportHookfromcubicweb.server.sources.storagesimportETYPE_ATTR_STORAGEclassBFSSHook(Hook):"""abstract class for bytes file-system storage hooks"""__abstract__=Truecategory='bfss'classPreAddEntityHook(BFSSHook):""""""__regid__='bfss_add_entity'events=('before_add_entity',)def__call__(self):etype=self.entity.__regid__forattrinETYPE_ATTR_STORAGE.get(etype,()):ETYPE_ATTR_STORAGE[etype][attr].entity_added(self.entity,attr)classPreUpdateEntityHook(BFSSHook):""""""__regid__='bfss_update_entity'events=('before_update_entity',)def__call__(self):etype=self.entity.__regid__forattrinETYPE_ATTR_STORAGE.get(etype,()):ETYPE_ATTR_STORAGE[etype][attr].entity_updated(self.entity,attr)classPreDeleteEntityHook(BFSSHook):""""""__regid__='bfss_delete_entity'events=('before_delete_entity',)def__call__(self):etype=self.entity.__regid__forattrinETYPE_ATTR_STORAGE.get(etype,()):ETYPE_ATTR_STORAGE[etype][attr].entity_deleted(self.entity,attr)