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.

leobject.py 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. #-*- coding: utf-8 -*-
  2. ## @package leobject API to access lodel datas
  3. #
  4. # This package contains abstract classes leobject.leclass.LeClass , leobject.letype.LeType, leobject.leobject._LeObject.
  5. # Those abstract classes are designed to be mother classes of dynamically generated classes ( see leobject.lefactory.LeFactory )
  6. ## @package leobject.leobject
  7. # @brief Abstract class designed to be implemented by LeObject
  8. #
  9. # @note LeObject will be generated by leobject.lefactory.LeFactory
  10. import re
  11. import leobject
  12. import EditorialModel
  13. from EditorialModel.types import EmType
  14. REL_SUP = 0
  15. REL_SUB = 1
  16. ## @brief Main class to handle objects defined by the types of an Editorial Model
  17. class _LeObject(object):
  18. ## @brief The editorial model
  19. _model = None
  20. ## @brief The datasource
  21. _datasource = None
  22. ## @brief maps em uid with LeType or LeClass keys are uid values are LeObject childs classes
  23. _me_uid = dict()
  24. _query_re = None
  25. _query_operators = ['=', '<=', '>=', '!=', '<', '>', ' in ', ' not in ']
  26. ## @brief Instantiate with a Model and a DataSource
  27. # @param **kwargs dict : datas usefull to instanciate a _LeObject
  28. def __init__(self, **kwargs):
  29. raise NotImplementedError("Abstract constructor")
  30. ## @brief Given a ME uid return the corresponding LeClass or LeType class
  31. # @return a LeType or LeClass child class
  32. # @throw KeyError if no corresponding child classes
  33. @classmethod
  34. def uid2leobj(cls, uid):
  35. uid = int(uid)
  36. if uid not in cls._me_uid:
  37. raise KeyError("No LeType or LeClass child classes with uid '%d'"%uid)
  38. return cls._me_uid[uid]
  39. ## @brief Creates new entries in the datasource
  40. # @param datas list : A list a dict with fieldname as key
  41. # @param cls
  42. # @return a list of inserted lodel_id
  43. # @see leobject.datasources.dummy.DummyDatasource.insert(), leobject.letype.LeType.insert()
  44. @classmethod
  45. def insert(cls, letype, datas):
  46. if isinstance(datas, dict):
  47. datas = [datas]
  48. if cls == _LeObject:
  49. raise NotImplementedError("Abstract method")
  50. letype,leclass = cls._prepare_targets(letype)
  51. if letype is None:
  52. raise ValueError("letype argument cannot be None")
  53. for data in datas:
  54. letype.check_datas_or_raise(data, complete = True)
  55. return cls._datasource.insert(letype, leclass, datas)
  56. ## @brief Check if a LeType is a hierarchy root
  57. @staticmethod
  58. def is_root(leo):
  59. if isinstance(leo, leobject.letype.LeType):
  60. return False
  61. elif isinstance(leo, LeRoot):
  62. return True
  63. raise ValueError("Invalid value for a LeType : %s"%leo)
  64. ## @brief Return a LeRoot instance
  65. @staticmethod
  66. def get_root():
  67. return LeRoot()
  68. ## @brief Delete LeObjects given filters
  69. # @param cls
  70. # @param letype LeType|str : LeType child class or name
  71. # @param leclass LeClass|str : LeClass child class or name
  72. # @param filters list : list of filters (see @ref leobject_filters)
  73. # @return bool
  74. @classmethod
  75. def delete(cls, letype, filters):
  76. letype, leclass = cls._prepare_targets(letype)
  77. filters,relationnal_filters = leobject.leobject._LeObject._prepare_filters(filters, letype, leclass)
  78. return cls._datasource.delete(letype, leclass, filters, relationnal_filters)
  79. ## @brief Update LeObjects given filters and datas
  80. # @param cls
  81. # @param letype LeType|str : LeType child class or name
  82. # @param filters list : list of filters (see @ref leobject_filters)
  83. @classmethod
  84. def update(cls, letype, filters, datas):
  85. letype, leclass = cls._prepare_targets(letype)
  86. filters,relationnal_filters = leobject.leobject._LeObject._prepare_filters(filters, letype, leclass)
  87. if letype is None:
  88. raise ValueError("Argument letype cannot be None")
  89. letype.check_datas_or_raise(datas, False)
  90. return cls._datasource.update(letype, leclass, filters, relationnal_filters, datas)
  91. ## @brief make a search to retrieve a collection of LeObject
  92. # @param query_filters list : list of string of query filters (or tuple (FIELD, OPERATOR, VALUE) ) see @ref leobject_filters
  93. # @param field_list list|None : list of string representing fields see @ref leobject_filters
  94. # @param typename str : The name of the LeType we want
  95. # @param classname str : The name of the LeClass we want
  96. # @param cls
  97. # @return responses ({string:*}): a list of dict with field:value
  98. @classmethod
  99. def get(cls, query_filters, field_list = None, typename = None, classname = None):
  100. letype,leclass = cls._prepare_targets(typename, classname)
  101. #Checking field_list
  102. if field_list is None or len(field_list) == 0:
  103. #default field_list
  104. if not (letype is None):
  105. field_list = letype._fields
  106. elif not (leclass is None):
  107. field_list = leclass._fieldtypes.keys()
  108. else:
  109. field_list = list(EditorialModel.classtypes.common_fields.keys())
  110. #Fetching LeType
  111. if letype is None:
  112. if 'type_id' not in field_list:
  113. field_list.append('type_id')
  114. field_list = cls._prepare_field_list(field_list, letype, leclass)
  115. #preparing filters
  116. filters, relationnal_filters = cls._prepare_filters(query_filters, letype, leclass)
  117. #Fetching datas from datasource
  118. datas = cls._datasource.get(leclass, letype, field_list, filters, relationnal_filters)
  119. #Instanciating corresponding LeType child classes with datas
  120. result = list()
  121. for leobj_datas in datas:
  122. letype = self.uid2leobj(datas['type_id']) if letype is None else letype
  123. result.append(letype(datas))
  124. return result
  125. ## @brief Link two leobject together using a rel2type field
  126. # @param lesup LeType : LeType child class instance linked as superior
  127. # @param lesub LeType : LeType child class instance linked as subordinate
  128. # @param **rel_attr : Relation attributes
  129. # @return True if linked without problems
  130. # @throw LeObjectError if the link is not valid
  131. # @throw LeObkectError if the link already exists
  132. # @throw AttributeError if an non existing relation attribute is given as argument
  133. # @throw ValueError if the relation attrivute value check fails
  134. #
  135. # @todo Code factorisation on relation check
  136. # @todo unit tests
  137. @classmethod
  138. def link_together(cls, lesup, lesub, rank = 'last', **rel_attr):
  139. if lesub.__class__ not in lesup._linked_types.keys():
  140. raise LeObjectError("Relation error : %s cannot be linked with %s"%(lesup.__class__.__name__, lesub.__class__.__name__))
  141. for attr_name in rel_attr.keys():
  142. if attr_name not in [ f for f,g in lesup._linked_types[lesub.__class__] ]:
  143. raise AttributeError("A rel2type between a %s and a %s doesn't have an attribute %s"%(lesup.__class__.__name__, lesub.__class__.__name__))
  144. if not sup._linked_types[lesub.__class__][1].check(rel_attr[attr_name]):
  145. raise ValueError("Wrong value '%s' for attribute %s"%(rel_attr[attr_name], attr_name))
  146. #Checks that attributes are uniq for this relation
  147. rels_attr = [ attrs for lesup, lesub, attrs in cls.links_get(lesup) if lesup == lesup ]
  148. for e_attrs in rels_attrs:
  149. if rel_attr == e_attrs:
  150. raise LeObjectError("Relation error : a relation with the same attributes already exists")
  151. return cls._datasource.add_related(lesup, lesub, rank, **rel_attr)
  152. ## @brief Get related objects
  153. # @param leo LeType(instance) : LeType child class instance
  154. # @param letype LeType(class) : the wanted LeType child class (not instance)
  155. # @param leo_is_superior bool : if True leo is the superior in the relation
  156. # @return A dict with LeType child class instance as key and dict {rel_attr_name:rel_attr_value, ...}
  157. # @throw LeObjectError if the relation is not possible
  158. #
  159. # @todo Code factorisation on relation check
  160. # @todo unit tests
  161. @classmethod
  162. def linked_together(cls, leo, letype, leo_is_superior = True):
  163. valid_link = letype in leo._linked_types.keys() if leo_is_superior else leo.__class__ in letype._linked_types.keys()
  164. if not valid_link:
  165. raise LeObjectError("Relation error : %s have no links with %s"%(
  166. leo.__class__ if leo_is_superior else letype,
  167. letype if leo_is_superior else leo.__class__
  168. ))
  169. return cls._datasource.get_related(leo, letype, leo_is_superior)
  170. ## @brief Fetch a relation and its attributes
  171. # @param id_relation int : the relation identifier
  172. # @return a tuple(lesup, lesub, dict_attr) or False if no relation exists with this id
  173. # @throw Exception if the relation is not a rel2type relation
  174. @classmethod
  175. def link_get(cls, id_relation):
  176. return cls._datasource.get_relation(id_relation)
  177. ## @brief Fetch all relations for an objects
  178. # @param leo LeType : LeType child class instance
  179. # @return a list of tuple (lesup, lesub, dict_attr)
  180. def links_get(cls, leo):
  181. return cls._datasource.get_relations(leo)
  182. ## @brief Remove a link (and attributes) between two LeObject
  183. # @param id_relation int : Relation identifier
  184. # @return True if a link has been deleted
  185. # @throw LeObjectError if the relation is not a rel2type
  186. #
  187. # @todo Code factorisation on relation check
  188. # @todo unit tests
  189. @classmethod
  190. def link_remove(cls, id_relation):
  191. if lesub.__class__ not in lesup._linked_types.keys():
  192. raise LeObjectError("Relation errorr : %s cannot be linked with %s"%(lesup.__class__.__name__, lesub.__class__.__name__))
  193. return cls._datasource.del_related(lesup, lesub)
  194. ## @brief Add a hierarchy relation between two LeObject
  195. # @param lesup LeType|LeRoot : LeType child class instance
  196. # @param lesub LeType : LeType child class instance
  197. # @param nature str : The nature of the relation @ref EditorialModel.classtypes
  198. # @param rank str|int : The relation rank. Can be 'last', 'first' or an integer
  199. # @param replace_if_exists bool : if True delete the old superior and set the new one. If False and there is a superior raise an LeObjectQueryError
  200. # @return The relation ID or False if fails
  201. # @throw LeObjectQueryError replace_if_exists == False and there is a superior
  202. @classmethod
  203. def hierarchy_add(cls, lesup, lesub, nature, rank = 'last', replace_if_exists = False):
  204. #Arguments check
  205. if nature not in EditorialModel.classtypes.EmClassType.natures(lesub._classtype):
  206. raise ValueError("Invalid nature '%s' for %s"%(nature, lesup.__class__.__name__))
  207. if not cls.leo_is_root(lesup):
  208. if nature not in EditorialModel.classtypes.EmClassType.natures(lesup._classtype):
  209. raise ValueError("Invalid nature '%s' for %s"%(nature, lesup.__class__.__name__))
  210. if lesup.__class__ not in lesub._superiors[nature]:
  211. raise ValueError("%s is not a valid superior for %s"%(lesup.__class__, lesub.__class__))
  212. #else:
  213. # lesup is not a LeType but a hierarchy root
  214. if rank not in ['first', 'last'] and not isinstance(rank, int):
  215. raise ValueError("Allowed values for rank are integers and 'first' or 'last' but '%s' found"%rank)
  216. superiors = cls.hierarchy_get(lesub, nature, leo_is_sup = False)
  217. if lesup in len(superiors) > 0:
  218. if not replace_if_exists:
  219. raise LeObjectQueryError("The subordinate allready has a superior")
  220. #remove existig superior
  221. if not cls.hierarchy_del(superiors[0], lesub, nature):
  222. raise RuntimeError("Unable to delete the previous superior")
  223. return self._datasource.add_superior(lesup, lesub, nature, rank)
  224. ## @brief Delete a hierarchy link between two LeObject
  225. # @param lesup LeType | LeRoot : LeType child class or hierarchy root
  226. # @param lesub LeType : LeType child class
  227. # @param nature str : The nature of the relation @ref EditorialModel.classtypes
  228. # @return True if deletion done successfully
  229. # @throw ValueError when bad arguments given
  230. @classmethod
  231. def hierarchy_del(cls, lesup, lesub, nature):
  232. if nature not in EditorialModel.classtypes.EmClassType.natures(lesub._classtype):
  233. raise ValueError("Invalid nature '%s' for %s"%(nature, lesup.__class__.__name__))
  234. if not cls.leo_is_root(lesup):
  235. if nature not in EditorialModel.classtypes.EmClassType.natures(lesup._classtype):
  236. raise ValueError("Invalid nature '%s' for %s"%(nature, lesup.__class__.__name__))
  237. if lesup.__class__ not in lesub._superiors[nature]:
  238. raise ValueError("%s is not a valid superior for %s"%(lesup.__class__, lesub.__class__))
  239. superiors = cls.hierarchy_get(lesub, nature, leo_is_sup = False)
  240. res = True
  241. for _lesup in superiors:
  242. if not cls._datasource.del_superior(_lesup, lesub, nature):
  243. #How to handler this ?
  244. res = False
  245. return res
  246. ## @brief Fetch neighbour in hierarchy relation
  247. # @param leo LeType | LeRoot : We want the neighbour of this LeObject (can be the root)
  248. # @param nature str : @ref EditorialModel.classtypes
  249. # @param leo_is_sup bool : if True leo is the superior and we want to fetch the subordinates else its the oposite
  250. # @return A list of LeObject ordered by depth if leo_is_sup, else a list of subordinates
  251. @classmethod
  252. def hierarchy_get(cls, leo, nature, leo_is_sup = True):
  253. #Checking arguments
  254. if not (nature is None) and not cls.is_root(leo):
  255. if nature not in EditorialModel.classtypes.EmClassType.natures(leo._classtype):
  256. raise ValueError("Invalid nature '%s' for %s"%(nature, lesup.__class__.__name__))
  257. if leo_is_sup:
  258. return cls._datasource.get_subordinates(leo, nature)
  259. else:
  260. return cls._datasource.get_superiors(leo, nature)
  261. ## @brief Prepare a field_list
  262. # @param field_list list : List of string representing fields
  263. # @param letype LeType : LeType child class
  264. # @param leclass LeClass : LeClass child class
  265. # @return A well formated field list
  266. @classmethod
  267. def _prepare_field_list(cls, field_list, letype, leclass):
  268. cls._check_fields(letype, leclass, [f for f in field_list if not cls._field_is_relational(f)])
  269. for i, field in enumerate(field_list):
  270. if cls._field_is_relational(field):
  271. field_list[i] = cls._prepare_relational_field(field)
  272. return field_list
  273. ## @brief Preparing letype and leclass arguments
  274. #
  275. # This function will do multiple things :
  276. # - Convert string to LeType or LeClass child instances
  277. # - If both letype and leclass given, check that letype inherit from leclass
  278. #  - If only a letype is given, fetch the parent leclass
  279. # @note If we give only a leclass as argument returned letype will be None
  280. # @note Its possible to give letype=None and leclass=None. In this case the method will return tuple(None,None)
  281. # @param letype LeType|str|None : LeType child instant or its name
  282. # @param leclass LeClass|str|None : LeClass child instant or its name
  283. # @return a tuple with 2 python classes (LeTypeChild, LeClassChild)
  284. @staticmethod
  285. def _prepare_targets(letype = None , leclass = None):
  286. if not(leclass is None):
  287. if isinstance(leclass, str):
  288. leclass = leobject.lefactory.LeFactory.leobj_from_name(leclass)
  289. if not isinstance(leclass, type) or not (leobject.leclass.LeClass in leclass.__bases__) or leclass.__class__ == leobject.leclass.LeClass:
  290. raise ValueError("None | str | LeType child class excpected, but got : '%s' %s"%(leclass,type(leclass)))
  291. if not(letype is None):
  292. if isinstance(letype, str):
  293. letype = leobject.lefactory.LeFactory.leobj_from_name(letype)
  294. if not isinstance(letype, type) or not leobject.letype.LeType in letype.__bases__ or letype.__class__ == leobject.letype.LeType:
  295. raise ValueError("None | str | LeType child class excpected, but got : %s"%type(letype))
  296. if leclass is None:
  297. leclass = letype._leclass
  298. elif leclass != letype._leclass:
  299. raise ValueError("LeType child class %s does'nt inherite from LeClass %s"%(letype.__name__, leclass.__name__))
  300. return (letype, leclass)
  301. ## @brief Check if a fieldname is valid
  302. # @param letype LeType|None : The concerned type (or None)
  303. # @param leclass LeClass|None : The concerned class (or None)
  304. # @param fields list : List of string representing fields
  305. # @throw LeObjectQueryError if their is some problems
  306. # @throw AttributeError if letype is not from the leclass class
  307. # @todo Delete the checks of letype and leclass and ensure that this method is called with letype and leclass arguments from _prepare_targets()
  308. #
  309. # @see @ref leobject_filters
  310. @staticmethod
  311. def _check_fields(letype, leclass, fields):
  312. #Checking that fields in the query_filters are correct
  313. if letype is None and leclass is None:
  314. #Only fields from the object table are allowed
  315. for field in fields:
  316. if field not in EditorialModel.classtypes.common_fields.keys():
  317. raise LeObjectQueryError("Not typename and no classname given, but the field %s is not in the common_fields list"%field)
  318. else:
  319. if letype is None:
  320. field_l = leclass._fieldtypes.keys()
  321. else:
  322. if not (leclass is None):
  323. if letype._leclass != leclass:
  324. raise AttributeError("The EmType %s is not a specialisation of the EmClass %s"%(typename, classname))
  325. field_l = letype._fields
  326. #Checks that fields are in this type
  327. for field in fields:
  328. if field not in field_l:
  329. raise LeObjectQueryError("No field named '%s' in '%s'"%(field, letype.__name__))
  330. pass
  331. ## @brief Prepare filters for datasource
  332. #
  333. # This method divide filters in two categories :
  334. # - filters : standart FIELDNAME OP VALUE filter
  335. # - relationnal_filters : filter on object relation RELATION_NATURE OP VALUE
  336. #
  337. # Both categories of filters are represented in the same way, a tuple with 3 elements (NAME|NAT , OP, VALUE )
  338. #
  339. # @warning This method assume that letype and leclass are returned from _LeObject._prepare_targets() method
  340. # @param filters_l list : This list can contain str "FIELDNAME OP VALUE" and tuples (FIELDNAME, OP, VALUE)
  341. # @param letype LeType|None : needed to check filters
  342. # @param leclass LeClass|None : needed to check filters
  343. # @return a tuple(FILTERS, RELATIONNAL_FILTERS
  344. #
  345. # @see @ref datasource_side
  346. @staticmethod
  347. def _prepare_filters(filters_l, letype = None, leclass = None):
  348. filters = list()
  349. for fil in filters_l:
  350. if len(fil) == 3 and not isinstance(fil, str):
  351. filters.append(tuple(fil))
  352. else:
  353. filters.append(_LeObject._split_filter(fil))
  354. #Checking relational filters (for the moment fields like superior.NATURE)
  355. relational_filters = [ (_LeObject._prepare_relational_field(field), operator, value) for field, operator, value in filters if _LeObject._field_is_relational(field)]
  356. filters = [f for f in filters if not _LeObject._field_is_relational(f[0])]
  357. #Checking the rest of the fields
  358. _LeObject._check_fields(letype, leclass, [ f[0] for f in filters ])
  359. return (filters, relational_filters)
  360. ## @brief Check if a field is relational or not
  361. # @param field str : the field to test
  362. # @return True if the field is relational else False
  363. @staticmethod
  364. def _field_is_relational(field):
  365. return field.startswith('superior.') or field.startswith('subordinate')
  366. ## @brief Check that a relational field is valid
  367. # @param field str : a relational field
  368. # @return a nature
  369. @staticmethod
  370. def _prepare_relational_field(field):
  371. spl = field.split('.')
  372. if len(spl) != 2:
  373. raise LeObjectQueryError("The relationalfield '%s' is not valid"%field)
  374. nature = spl[-1]
  375. if nature not in EditorialModel.classtypes.EmNature.getall():
  376. raise LeObjectQueryError("'%s' is not a valid nature in the field %s"%(nature, field))
  377. if spl[0] == 'superior':
  378. return (REL_SUP, nature)
  379. elif spl[0] == 'subordinate':
  380. return (REL_SUB, nature)
  381. else:
  382. raise LeObjectQueryError("Invalid preffix for relationnal field : '%s'"%spl[0])
  383. ## @brief Check and split a query filter
  384. # @note The query_filter format is "FIELD OPERATOR VALUE"
  385. # @param query_filter str : A query_filter string
  386. # @param cls
  387. # @return a tuple (FIELD, OPERATOR, VALUE)
  388. @classmethod
  389. def _split_filter(cls, query_filter):
  390. if cls._query_re is None:
  391. cls._compile_query_re()
  392. matches = cls._query_re.match(query_filter)
  393. if not matches:
  394. raise ValueError("The query_filter '%s' seems to be invalid"%query_filter)
  395. result = (matches.group('field'), re.sub(r'\s', ' ', matches.group('operator'), count=0), matches.group('value').strip())
  396. for r in result:
  397. if len(r) == 0:
  398. raise ValueError("The query_filter '%s' seems to be invalid"%query_filter)
  399. return result
  400. ## @brief Compile the regex for query_filter processing
  401. # @note Set _LeObject._query_re
  402. @classmethod
  403. def _compile_query_re(cls):
  404. op_re_piece = '(?P<operator>(%s)'%cls._query_operators[0].replace(' ', '\s')
  405. for operator in cls._query_operators[1:]:
  406. op_re_piece += '|(%s)'%operator.replace(' ', '\s')
  407. op_re_piece += ')'
  408. cls._query_re = re.compile('^\s*(?P<field>(((superior)|(subordinate))\.)?[a-z_][a-z0-9\-_]*)\s*'+op_re_piece+'\s*(?P<value>[^<>=!].*)\s*$', flags=re.IGNORECASE)
  409. pass
  410. ## @brief Class designed to represent the hierarchy roots
  411. # @see _LeObject.get_root() _LeObject.is_root()
  412. class LeRoot(object):
  413. pass
  414. class LeObjectError(Exception):
  415. pass
  416. class LeObjectQueryError(LeObjectError):
  417. pass
  418. ## @page leobject_filters LeObject query filters
  419. # The LeObject API provide methods that accept filters allowing the user
  420. # to query the database and fetch LodelEditorialObjects.
  421. #
  422. # The LeObject API translate those filters for the datasource.
  423. #
  424. # @section api_user_side API user side filters
  425. # Filters are string expressing a condition. The string composition
  426. # is as follow : "<FIELD> <OPERATOR> <VALUE>"
  427. # @subsection fpart FIELD
  428. # @subsubsection standart fields
  429. # Standart fields, represents a value of the LeObject for example "title", "lodel_id" etc.
  430. # @subsubsection rfields relationnal fields
  431. # relationnal fields, represents a relation with the object hierarchy. Those fields are composed as follow :
  432. # "<RELATION>.<NATURE>".
  433. #
  434. # - Relation can takes two values : superiors or subordinates
  435. # - Nature is a relation nature ( see EditorialModel.classtypes )
  436. # Examples : "superiors.parent", "subordinates.translation" etc.
  437. # @note The field_list arguement of leobject.leobject._LeObject.get() use the same syntax than the FIELD filter part
  438. # @subsection oppart OPERATOR
  439. # The OPERATOR part of a filter is a comparison operator. There is
  440. # - standart comparison operators : = , <, > , <=, >=, !=
  441. # - list operators : 'in' and 'not in'
  442. # The list of allowed operators is sotred at leobject.leobject._LeObject._query_operators .
  443. # @subsection valpart VALUE
  444. # The VALUE part of a filter is... just a value...
  445. #
  446. # @section datasource_side Datasource side filters
  447. # As said above the API "translate" filters before forwarding them to the datasource.
  448. #
  449. # The translation process transform filters in tuple composed of 3 elements
  450. # ( @ref fpart , @ref oppart , @ref valpart ). Each element is a string.
  451. #
  452. # There is a special case for @ref rfields : the field element is a tuple composed with two elements
  453. # ( RELATION, NATURE ) where NATURE is a string ( see EditorialModel.classtypes ) and RELATION is one of
  454. # the defined constant :
  455. #
  456. # - leobject.leobject.REL_SUB for "subordinates"
  457. # - leobject.leobject.REL_SUP for "superiors"
  458. #
  459. # @note The filters translation process also check if given field are valids compared to the concerned letype and/or the leclass