[Mpuls-commits] r5430 - waska/trunk/waskaweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Oct 7 21:07:17 CEST 2011


Author: bh
Date: 2011-10-07 21:07:16 +0200 (Fri, 07 Oct 2011)
New Revision: 5430

Modified:
   waska/trunk/waskaweb/lib/search.py
Log:
Make the search AppMixin class work for the most part:
AppMixin must be first base class of CaseSearch and EvaluationSearch.
The code in AppMixin has to always use super() to call the inherited
method so that the method from the correct base class is called.
The class variables VALID_OPTIONS and MULTI_OPTIONS have to be handled
correctly.

The only thing missing is the validation which currently won't work for
the evaluation search.


Modified: waska/trunk/waskaweb/lib/search.py
===================================================================
--- waska/trunk/waskaweb/lib/search.py	2011-10-07 18:58:09 UTC (rev 5429)
+++ waska/trunk/waskaweb/lib/search.py	2011-10-07 19:07:16 UTC (rev 5430)
@@ -41,11 +41,10 @@
 
 class AppMixin(object):
 
-    VALID_OPTIONS = (CaseBaseSearch.VALID_OPTIONS
-                     + ("gender", "type_ending"))
-    MULTI_OPTIONS = (CaseBaseSearch.MULTI_OPTIONS
-                     + ("type_ending",))
+    VALID_OPTIONS = ("gender", "type_ending")
 
+    MULTI_OPTIONS = ("type_ending",)
+
     def validate_form_params(self, params):
         # FIXME: We import SearchCaseForm here because importing it
         # during import doesn't work.  The validators module performs
@@ -59,8 +58,8 @@
         return validator.to_python(params)
 
     def convert_form_parameters(self, options, user, extended):
-        search = CaseBaseSearch.convert_form_parameters(self, options, user,
-                                                        extended=extended)
+        search = super(AppMixin, self).convert_form_parameters(options, user,
+                                                            extended=extended)
         if extended:
             type_ending = options.get("type_ending")
             if type_ending:
@@ -86,17 +85,25 @@
         return "TRUE"
 
     def get_where_subclauses(self, options):
-        return CaseBaseSearch.get_where_subclauses(self, options) + [
+        return super(AppMixin, self).get_where_subclauses(options) + [
             self.get_ending_clause(options),
             ]
 
-class CaseSearch(CaseBaseSearch, AppMixin):
 
-    pass
+class CaseSearch(AppMixin, CaseBaseSearch):
 
-class EvaluationSearch(EvaluationBaseSearch, AppMixin):
+    VALID_OPTIONS = (CaseBaseSearch.VALID_OPTIONS + AppMixin.VALID_OPTIONS)
 
-    pass
+    MULTI_OPTIONS = (CaseBaseSearch.MULTI_OPTIONS + AppMixin.MULTI_OPTIONS)
 
 
+class EvaluationSearch(AppMixin, EvaluationBaseSearch):
+
+    VALID_OPTIONS = (EvaluationBaseSearch.VALID_OPTIONS
+                     + AppMixin.VALID_OPTIONS)
+
+    MULTI_OPTIONS = (EvaluationBaseSearch.MULTI_OPTIONS
+                     + AppMixin.MULTI_OPTIONS)
+
+
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:



More information about the Mpuls-commits mailing list