No Description
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.

lerelation.py 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #-*- coding: utf-8 -*-
  2. import copy
  3. import EditorialModel.fieldtypes.leo as ft_leo
  4. from . import lecrud
  5. ## @brief Main class for relations
  6. class _LeRelation(lecrud._LeCrud):
  7. ## @brief Handles the superior
  8. _lesup_fieldtype = ft_leo.EmFieldType(True)
  9. ## @brief Handles the subordinate
  10. _lesub_fieldtype = ft_leo.EmFieldType(False)
  11. ## @brief Stores the list of fieldtypes that are common to all relations
  12. _rel_fieldtypes = dict()
  13. ## @brief Stores the list of fieldtypes handling relations attributes
  14. _rel_attr_fieldtypes = dict()
  15. def __init__(self, rel_id, **kwargs):
  16. pass
  17. @classmethod
  18. def fieldtypes(cls):
  19. rel_ft = dict()
  20. rel_ft.update(cls._lesup_fieldtype)
  21. rel_ft.update(cls._lesub_fieldtype)
  22. rel_ft.update(cls._rel_fieldtypes)
  23. rel_ft.update(cls._rel_attr_fieldtypes)
  24. return rel_ft
  25. @classmethod
  26. def _prepare_relational_fields(cls, field):
  27. return LeApiQueryError("Relational field '%s' given but %s doesn't is not a LeObject"%(field,cls.__name__))
  28. ## @brief Abstract class to handle hierarchy relations
  29. class _LeHierarch(_LeRelation):
  30. def __init__(self, rel_id):
  31. pass
  32. ## @brief Abstract class to handle rel2type relations
  33. class _LeRel2Type(_LeRelation):
  34. pass