code: def _set_value(self, entity, value):
      
      if value is not None:
        value = _validate_key(value, entity=entity)
        value = entity._validate_key(value)
      entity._entity_key = value
docs: Setter for key attribute.