[Mpuls-commits] r5469 - base/trunk/mpulsweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Oct 14 11:59:45 CEST 2011
Author: bh
Date: 2011-10-14 11:59:45 +0200 (Fri, 14 Oct 2011)
New Revision: 5469
Modified:
base/trunk/mpulsweb/controllers/case_overview.py
Log:
Distinguish between form_results and form_defaults in case overview.
The values in the form_results dictionary are validated python objects
returned by the validator's to_python method. The form_defaults
dictionary contains the same values as strings to be used when rendering
the form and can be created with the validator's from_python method or
taken from the Invalid exception. Confusing these dictionaries as is
done in many places in mpuls, can lead to errors.
Distinguishing them properly is especially important when dealing with
date objects as values. The default serialization that would be used
when rendering them in forms would be the ISO format, not the german
date format preferred in mpuls.
Modified: base/trunk/mpulsweb/controllers/case_overview.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_overview.py 2011-10-14 09:17:40 UTC (rev 5468)
+++ base/trunk/mpulsweb/controllers/case_overview.py 2011-10-14 09:59:45 UTC (rev 5469)
@@ -106,8 +106,7 @@
cases.search(options)
return cases
- def _renderOverview(self, cases, form_defaults, form_errors):
-
+ def _renderOverview(self, cases, form_results, form_defaults, form_errors):
user = session['USER_AUTHORIZED']
# Values used in the template
c.extended_search = session.get('EXTENDED_SEARCH', False)
@@ -130,7 +129,7 @@
# Hide evaluation option if someone did a search for a particular editor
c.hide_evaluation = False
- if form_defaults.get('editor') != -1:
+ if form_results.get('editor') != -1:
c.hide_evaluation = True
session["id_field_candidate"] = "m.id"
@@ -143,28 +142,33 @@
@checkRole(('admin', 'cm', 'pt_dlr'))
def search(self, search_options=None):
-
- form_result = {}
+ validator = g.case_search.get_form_validator()
+ form_result = {}
form_errors = {}
+ form_defaults = None
if search_options is None:
search_options = {}
form_result.update(search_options_from_session())
else:
- form_result.update(search_options)
+ form_result.update(search_options)
if not search_options:
try:
- form_result.update(g.case_search.validate_form_params(request.params))
+ form_result.update(validator.to_python(request.params))
search_options.update(form_result)
session['CASE_OVERVIEW_SEARCHOPTIONS'] = search_options
session.save()
except formencode.Invalid, error:
log.exception("search: formencode error %s" % error)
- form_result = error.value
+ form_defaults = error.value
form_errors = error.error_dict or {}
+ if form_defaults is None:
+ form_defaults = validator.from_python(form_result)
+
cases = self._getCaseList(search_options)
- return self._renderOverview(cases, form_result, form_errors)
+ return self._renderOverview(cases, form_result, form_defaults,
+ form_errors)
def parseSearchOptions(self, options, extended):
return parseSearchOptions(options, extended)
More information about the Mpuls-commits
mailing list