[Mpuls-commits] r3664 - base/trunk/mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 16 10:45:43 CEST 2010


Author: torsten
Date: 2010-09-16 10:45:43 +0200 (Thu, 16 Sep 2010)
New Revision: 3664

Modified:
   base/trunk/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py (MpulsCase.check_anonymizeability): Implement check if only the minimal required fields of a cases must be filled out to anonymize a case.


Modified: base/trunk/mpulsweb/model/case.py
===================================================================
--- base/trunk/mpulsweb/model/case.py	2010-09-16 07:31:55 UTC (rev 3663)
+++ base/trunk/mpulsweb/model/case.py	2010-09-16 08:45:43 UTC (rev 3664)
@@ -37,9 +37,10 @@
 from pylons import config
 from mpulsweb.lib.translation import _
 
-from formed.meta.data import RepeatNode, DateLeaf, IntLeaf, TextLeaf, ChoiceNode
+from formed.meta.data import RepeatNode, DateLeaf, IntLeaf, TextLeaf, ChoiceNode, RuleLeaf
 from formed.instance.backends.postgres import DBFactory as InstanceFactory
 from formed.instance.backends.xmlimport import XMLImporter, XMLImportException
+from formed.instance.backends.common import RuleEvalContext
 from formed.instance.tree import SetDataException
 
 from libmpuls.service.tags import TagSetterConfig, TagSetter
@@ -740,20 +741,23 @@
 
         # 2. Now determine if we will enforce full consistence or minimal
         # consistence (e.g on abort)
+        self._load_formed_instance_tree()
         minimal_condition = g.mpuls_config.get(
                                 'phases', 'minimal_consistence_conditon')
-
-        if True: # TODO: Evaluation minimalcondition
+        context = RuleEvalContext(self.formed_instance, "XXX:%s" % self.id)
+        minimal_rule = RuleLeaf()
+        minimal_rule.setAttribute('expr', minimal_condition)
+        if minimal_rule.getExpr().evaluate(context):
+            # Check minimal consistence. Also running cases can be anonymized.
+            min_fields = g.mpuls_config.get('phases', 'minimal_fields_to_anonymize') 
+            self.check_consistence(min_fields)
+        else:
             #Check full consistence
             self.check_consistence()
             # 3. Check if the case is currently running 
             if isinstance(phasepart, StartPhasePart):
                 raise ConsistenceCheckException(
                             h.literal(MARKANONYMIZE_FAILED_RUNNING_PHASE % desc))
-        else:
-            # Check minimal consistence. Also running cases can be anonymized.
-            min_fields = g.mpuls_config.get('phases', 'minimal_fields_to_anonymize') 
-            self.check_consistence(min_fields)
 
     def make_consistent(self):
         """Will ensure that the case is in a (minimal) consistent state. That



More information about the Mpuls-commits mailing list