Geen omschrijving
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.

leclass.py 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #-*- coding: utf-8 -*-
  2. import leapi
  3. from leapi.leobject import _LeObject
  4. ## @brief Represent an EmClass data instance
  5. # @note Is not a derivated class of LeObject because the concrete class will be a derivated class from LeObject
  6. class _LeClass(_LeObject):
  7. ## @brief Stores fieldtypes by field name
  8. _fieldtypes = dict()
  9. ## @brief Stores authorized link2type
  10. _linked_types = list()
  11. ## @brief Stores fieldgroups and the fields they contains
  12. _fieldgroups = dict()
  13. ## @brief Stores the EM uid
  14. _class_id = None
  15. ## @brief Stores the classtype
  16. _classtype = None
  17. ## @brief Return a dict with fieldname as key and a fieldtype instance as value
  18. # @note not optimised at all
  19. @classmethod
  20. def fieldtypes(cls, complete=True):
  21. if complete:
  22. ret = dict()
  23. ret.update(super().fieldtypes())
  24. ret.update(cls._fieldtypes)
  25. return ret
  26. else:
  27. leobject = cls.name2class('LeObject')
  28. return { fname: cls._fieldtypes[fname] for fname in cls._fieldtypes if fname not in leobject.fieldtypes().keys() }
  29. @classmethod
  30. def fieldlist(cls, complete=True):
  31. return list(cls.fieldtypes(complete).keys())
  32. @classmethod
  33. def get(cls, query_filters, field_list=None, order=None, group=None, limit=None, offset=0):
  34. query_filters.append(('class_id', '=', cls._class_id))
  35. return super().get(query_filters, field_list, order=order, group=group, limit=limit, offset=offset)
  36. @classmethod
  37. def leo_class(cls):
  38. return cls