|
@@ -228,7 +228,7 @@ class _LeObject(object):
|
228
|
228
|
filters.append(_LeObject._split_filter(fil))
|
229
|
229
|
|
230
|
230
|
#Checking relational filters (for the moment fields like superior.NATURE)
|
231
|
|
- relational_filters = [ (_LeObject._nature_from_relational_field(field), operator, value) for field, operator, value in filters if _LeObject._field_is_relational(field)]
|
|
231
|
+ relational_filters = [ (_LeObject._prepare_relational_field(field), operator, value) for field, operator, value in filters if _LeObject._field_is_relational(field)]
|
232
|
232
|
filters = [f for f in filters if not _LeObject._field_is_relational(f[0])]
|
233
|
233
|
#Checking the rest of the fields
|
234
|
234
|
_LeObject._check_fields(letype, leclass, [ f[0] for f in filters ])
|
|
@@ -241,20 +241,26 @@ class _LeObject(object):
|
241
|
241
|
# @return True if the field is relational else False
|
242
|
242
|
@staticmethod
|
243
|
243
|
def _field_is_relational(field):
|
244
|
|
- return field.startswith('superior.')
|
|
244
|
+ return field.startswith('superior.') or field.startswith('subordinate')
|
245
|
245
|
|
246
|
246
|
## @brief Check that a relational field is valid
|
247
|
247
|
# @param field str : a relational field
|
248
|
248
|
# @return a nature
|
249
|
249
|
@staticmethod
|
250
|
|
- def _nature_from_relational_field(field):
|
|
250
|
+ def _prepare_relational_field(field):
|
251
|
251
|
spl = field.split('.')
|
252
|
252
|
if len(spl) != 2:
|
253
|
253
|
raise LeObjectQueryError("The relationalfield '%s' is not valid"%field)
|
254
|
254
|
nature = spl[-1]
|
255
|
255
|
if nature not in EditorialModel.classtypes.EmNature.getall():
|
256
|
256
|
raise LeObjectQueryError("'%s' is not a valid nature in the field %s"%(nature, field))
|
257
|
|
- return nature
|
|
257
|
+
|
|
258
|
+ if spl[0] == 'superior':
|
|
259
|
+ return (REL_SUP, nature)
|
|
260
|
+ elif spl[0] == 'subordinate':
|
|
261
|
+ return (REL_SUB, nature)
|
|
262
|
+ else:
|
|
263
|
+ raise LeObjectQueryError("Invalid preffix for relationnal field : '%s'"%spl[0])
|
258
|
264
|
|
259
|
265
|
## @brief Check and split a query filter
|
260
|
266
|
# @note The query_filter format is "FIELD OPERATOR VALUE"
|
|
@@ -284,7 +290,7 @@ class _LeObject(object):
|
284
|
290
|
for operator in cls._query_operators[1:]:
|
285
|
291
|
op_re_piece += '|(%s)'%operator.replace(' ', '\s')
|
286
|
292
|
op_re_piece += ')'
|
287
|
|
- cls._query_re = re.compile('^\s*(?P<field>(superior\.)?[a-z_][a-z0-9\-_]*)\s*'+op_re_piece+'\s*(?P<value>[^<>=!].*)\s*$', flags=re.IGNORECASE)
|
|
293
|
+ 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)
|
288
|
294
|
pass
|
289
|
295
|
|
290
|
296
|
class LeObjectError(Exception):
|