|
@@ -16,6 +16,9 @@ import leobject
|
16
|
16
|
import EditorialModel
|
17
|
17
|
from EditorialModel.types import EmType
|
18
|
18
|
|
|
19
|
+REL_SUP = 0
|
|
20
|
+REL_SUB = 1
|
|
21
|
+
|
19
|
22
|
## @brief Main class to handle objects defined by the types of an Editorial Model
|
20
|
23
|
class _LeObject(object):
|
21
|
24
|
|
|
@@ -95,8 +98,8 @@ class _LeObject(object):
|
95
|
98
|
return okay
|
96
|
99
|
|
97
|
100
|
## @brief make a search to retrieve a collection of LeObject
|
98
|
|
- # @param query_filters list : list of string of query filters (or tuple (FIELD, OPERATOR, VALUE) )
|
99
|
|
- # @param field_list list|None : list of string representing fields
|
|
101
|
+ # @param query_filters list : list of string of query filters (or tuple (FIELD, OPERATOR, VALUE) ) see @ref leobject_filters
|
|
102
|
+ # @param field_list list|None : list of string representing fields see @ref leobject_filters
|
100
|
103
|
# @param typename str : The name of the LeType we want
|
101
|
104
|
# @param classname str : The name of the LeClass we want
|
102
|
105
|
# @return responses ({string:*}): a list of dict with field:value
|
|
@@ -176,6 +179,8 @@ class _LeObject(object):
|
176
|
179
|
# @throw LeObjectQueryError if their is some problems
|
177
|
180
|
# @throw AttributeError if letype is not from the leclass class
|
178
|
181
|
# @todo Delete the checks of letype and leclass and ensure that this method is called with letype and leclass arguments from _prepare_targets()
|
|
182
|
+ #
|
|
183
|
+ # @see @ref leobject_filters
|
179
|
184
|
@staticmethod
|
180
|
185
|
def _check_fields(letype, leclass, fields):
|
181
|
186
|
#Checking that fields in the query_filters are correct
|
|
@@ -210,7 +215,9 @@ class _LeObject(object):
|
210
|
215
|
# @param filters_l list : This list can contain str "FIELDNAME OP VALUE" and tuples (FIELDNAME, OP, VALUE)
|
211
|
216
|
# @param letype LeType|None : needed to check filters
|
212
|
217
|
# @param leclass LeClass|None : needed to check filters
|
213
|
|
- # @return a tuple(FILTERS, RELATIONNAL_FILTERS°
|
|
218
|
+ # @return a tuple(FILTERS, RELATIONNAL_FILTERS
|
|
219
|
+ #
|
|
220
|
+ # @see @ref datasource_side
|
214
|
221
|
@staticmethod
|
215
|
222
|
def _prepare_filters(filters_l, letype = None, leclass = None):
|
216
|
223
|
filters = list()
|
|
@@ -285,3 +292,46 @@ class LeObjectError(Exception):
|
285
|
292
|
|
286
|
293
|
class LeObjectQueryError(LeObjectError):
|
287
|
294
|
pass
|
|
295
|
+
|
|
296
|
+## @page leobject_filters LeObject query filters
|
|
297
|
+# The LeObject API provide methods that accept filters allowing the user
|
|
298
|
+# to query the database and fetch LodelEditorialObjects.
|
|
299
|
+#
|
|
300
|
+# The LeObject API translate those filters for the datasource.
|
|
301
|
+#
|
|
302
|
+# @section api_user_side API user side filters
|
|
303
|
+# Filters are string expressing a condition. The string composition
|
|
304
|
+# is as follow : "<FIELD> <OPERATOR> <VALUE>"
|
|
305
|
+# @subsection fpart FIELD
|
|
306
|
+# @subsubsection standart fields
|
|
307
|
+# Standart fields, represents a value of the LeObject for example "title", "lodel_id" etc.
|
|
308
|
+# @subsubsection rfields relationnal fields
|
|
309
|
+# relationnal fields, represents a relation with the object hierarchy. Those fields are composed as follow :
|
|
310
|
+# "<RELATION>.<NATURE>".
|
|
311
|
+#
|
|
312
|
+# - Relation can takes two values : superiors or subordinates
|
|
313
|
+# - Nature is a relation nature ( see EditorialModel.classtypes )
|
|
314
|
+# Examples : "superiors.parent", "subordinates.translation" etc.
|
|
315
|
+# @note The field_list arguement of leobject.leobject._LeObject.get() use the same syntax than the FIELD filter part
|
|
316
|
+# @subsection oppart OPERATOR
|
|
317
|
+# The OPERATOR part of a filter is a comparison operator. There is
|
|
318
|
+# - standart comparison operators : = , <, > , <=, >=, !=
|
|
319
|
+# - list operators : 'in' and 'not in'
|
|
320
|
+# The list of allowed operators is sotred at leobject.leobject._LeObject._query_operators .
|
|
321
|
+# @subsection valpart VALUE
|
|
322
|
+# The VALUE part of a filter is... just a value...
|
|
323
|
+#
|
|
324
|
+# @section datasource_side Datasource side filters
|
|
325
|
+# As said above the API "translate" filters before forwarding them to the datasource.
|
|
326
|
+#
|
|
327
|
+# The translation process transform filters in tuple composed of 3 elements
|
|
328
|
+# ( @ref fpart , @ref oppart , @ref valpart ). Each element is a string.
|
|
329
|
+#
|
|
330
|
+# There is a special case for @ref rfields : the field element is a tuple composed with two elements
|
|
331
|
+# ( RELATION, NATURE ) where NATURE is a string ( see EditorialModel.classtypes ) and RELATION is one of
|
|
332
|
+# the defined constant :
|
|
333
|
+#
|
|
334
|
+# - leobject.leobject.REL_SUB for "subordinates"
|
|
335
|
+# - leobject.leobject.REL_SUP for "superiors"
|
|
336
|
+#
|
|
337
|
+# @note The filters translation process also check if given field are valids compared to the concerned letype and/or the leclass
|