diff --git a/src/linkahead/common/models.py b/src/linkahead/common/models.py index f6447cde255dea8f473acd51bc6953bc0bbefd6b..6f38ff40a46b9bd9fe9236cc2cd4b071c2f2af7c 100644 --- a/src/linkahead/common/models.py +++ b/src/linkahead/common/models.py @@ -183,6 +183,7 @@ class Entity: Special attributes, as defined by the global variable SPECIAL_ATTRIBUTES and additionaly the "value" are copied using setattr. """ + new: Union[File, Property, RecordType, Record, Entity] if self.role == "File": new = File() elif self.role == "Property": @@ -462,6 +463,8 @@ class Entity: def revoke_denial(self, realm=None, username=None, role=None, permission=None, priority=False): + if self.acl is None: + raise EntityHasNoAclError("This entity does not have an ACL (yet).") self.acl.revoke_denial( realm=realm, username=username, @@ -471,6 +474,8 @@ class Entity: def revoke_grant(self, realm=None, username=None, role=None, permission=None, priority=False): + if self.acl is None: + raise EntityHasNoAclError("This entity does not have an ACL (yet).") self.acl.revoke_grant( realm=realm, username=username, @@ -1464,6 +1469,8 @@ out: List[Entity] raise TransactionError(ae) else: e = Container().retrieve(query=self.id, sync=False)[0] + if self.acl is None: + raise EntityHasNoAclError("This entity does not have an ACL yet. Please set one first.") e.acl = ACL(self.acl.to_xml()) e.update() @@ -2443,6 +2450,7 @@ class _Properties(list): return self def to_xml(self, add_to_element: etree._Element, add_properties: INHERITANCE): + p: Property for p in self: importance = self._importance.get(p) @@ -3581,7 +3589,8 @@ class Container(list): if is_list_datatype(prop_dt): ref_name = get_list_datatype(prop_dt) try: - is_being_referenced.add(container.get_entity_by_name(ref_name).id) # type: ignore + is_being_referenced.add( + container.get_entity_by_name(ref_name).id) # type: ignore except KeyError: pass elif isinstance(prop_dt, str): @@ -4759,7 +4768,8 @@ class Query(): next_page = self._query_request(query_dict) etag = next_page.query.etag if etag is not None and etag != self.etag: - raise PagingConsistencyError("The database state changed while retrieving the pages") + raise PagingConsistencyError( + "The database state changed while retrieving the pages") yield next_page index += page_length