[Mpuls-commits] r5466 - base/trunk/mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Oct 13 19:56:26 CEST 2011
Author: bh
Date: 2011-10-13 19:56:26 +0200 (Thu, 13 Oct 2011)
New Revision: 5466
Modified:
base/trunk/mpulsweb/lib/search.py
Log:
Extract the get_form_validator method from validate_form_params
in the search classes.
The new method get_form_validator only instantiates the validator now
and validate_form_params now calls get_form_validator to get the
validator and then calls its to_python method. The EvaluationSearch
class does not need the validate_form_params method anymore because it
would be identical to the inherited method.
Modified: base/trunk/mpulsweb/lib/search.py
===================================================================
--- base/trunk/mpulsweb/lib/search.py 2011-10-13 16:19:52 UTC (rev 5465)
+++ base/trunk/mpulsweb/lib/search.py 2011-10-13 17:56:26 UTC (rev 5466)
@@ -168,6 +168,9 @@
return self.queryDB(self._build_sql(options))
def validate_form_params(self, params):
+ return self.get_form_validator().to_python(params)
+
+ def get_form_validator(self):
# FIXME: We import SearchCaseForm here because importing it
# during import doesn't work. The validators module performs
# translations and accesses app_globals during import, so it has
@@ -175,7 +178,7 @@
# search module is imported early on when the application starts
# so validators cannot be imported then.
from mpulsweb.lib.validators import SearchCaseForm
- return SearchCaseForm(**self.extra_validators()).to_python(params)
+ return SearchCaseForm(**self.extra_validators())
def extra_validators(self):
"""Return additional application specific validators.
@@ -536,7 +539,7 @@
self.retrieve_fields = retrieve_fields
self.match_fields = match_fields
- def validate_form_params(self, params):
+ def get_form_validator(self):
# FIXME: We import EvaluationSearchCaseForm here because importing it
# during import doesn't work. The validators module performs
# translations and accesses app_globals during import, so it has
@@ -544,8 +547,7 @@
# search module is imported early on when the application starts
# so validators cannot be imported then.
from mpulsweb.lib.validators import EvaluationSearchCaseForm
- validator = EvaluationSearchCaseForm(**self.extra_validators())
- return validator.to_python(params)
+ return EvaluationSearchCaseForm(**self.extra_validators())
def get_needle_clause(self, options):
"""Return the search condition to select cases based on search terms.
More information about the Mpuls-commits
mailing list