Нема описа
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345678910111213141516171819202122232425
  1. # -*- coding: utf-8 -*-
  2. from lodel.leapi.datahandlers.field_data_handler import FieldValidationError
  3. from lodel.leapi.datahandlers.reference import Reference
  4. from lodel.editorial_model.components import EmClass
  5. class DataHandler(Reference):
  6. ## @brief instanciates a dict reference
  7. # @param allowed_classes list | None : list of allowed em classes if None no restriction
  8. # @param internal bool : if False, the field is not internal
  9. # @param kwargs : Other named arguments
  10. def __init__(self, allowed_classes=None, internal=False, **kwargs):
  11. super().__init__(allowed_classes=allowed_classes, internal=internal, **kwargs)
  12. ## @brief Check value
  13. # @param value *
  14. # @return tuple(value, exception)
  15. def _check_data_value(self, value):
  16. if not isinstance(value, dict):
  17. return None, FieldValidationError("Values for dict fields should be dict")
  18. val, expt = super()._check_data_value(value.values())
  19. return (
  20. None if isinstance(expt, Exception) else value,
  21. expt)