Rewriting of a cryptic comment.

This commit is contained in:
Mikaël Ates 2011-08-26 11:36:35 +02:00
parent 83fc3d5a36
commit 1c7df14986
1 changed files with 14 additions and 7 deletions

View File

@ -719,7 +719,6 @@ def check_data_and_create_permission(request, who, what, how):
single_value = True
pred = PredicateRequired(definition=ad, rule=rule, single_value=single_value)
else:
if not 'multivalues_step_two' in predicate \
or not 'multivalues_explanation' in predicate \
or not predicate['multivalues_step_two'] in \
@ -780,6 +779,20 @@ def check_data_and_create_permission(request, who, what, how):
rule=rule)
pred.save()
'''
Here we substitute friendly predicate identifiers (displayed on
the GUI) with their primary key.
The substitution might fail if some primary keys are equal to
friendly identifiers since with an iterative substitution, a
primary key resulting from a previsous substitution would be
replaced by another primary key.
To prevent this we realize a two-round substitution with unique
identifiers.
'''
rdm_str = ''.join(random.choice(string.ascii_uppercase) for x in range(8))
p_ids1[p_id] = rdm_str
p_ids2[rdm_str] = pred.id
@ -791,12 +804,6 @@ def check_data_and_create_permission(request, who, what, how):
if not is_proposition(expression):
raise Exception('The logic expression is malformed')
'''
Pb if a predicate id is equal to value.
The value of the predicate will be substitue with a predicate
with that id.
Solution: make a first substitution with unique identifiers.
'''
for key in p_ids1.keys():
expression = re.sub(str(key), str(p_ids1[key]), expression)
for key in p_ids2.keys():