[Mpuls-commits] r3465 - in base/trunk: . mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Aug 27 13:01:06 CEST 2010
Author: bh
Date: 2010-08-27 13:01:05 +0200 (Fri, 27 Aug 2010)
New Revision: 3465
Modified:
base/trunk/ChangeLog
base/trunk/mpulsweb/lib/search.py
Log:
* mpulsweb/lib/search.py (CaseSearch.get_where_subclauses)
(CaseSearch.get_where): Move the code that gathers all the
sub-clauses into the separate method get_where_subclauses that
returns a list with all the sub-clauses. This makes it easier for
derived classes to add new sub-clauses.
Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog 2010-08-27 10:38:05 UTC (rev 3464)
+++ base/trunk/ChangeLog 2010-08-27 11:01:05 UTC (rev 3465)
@@ -1,5 +1,13 @@
2010-08-27 Bernhard Herzog <bh at intevation.de>
+ * mpulsweb/lib/search.py (CaseSearch.get_where_subclauses)
+ (CaseSearch.get_where): Move the code that gathers all the
+ sub-clauses into the separate method get_where_subclauses that
+ returns a list with all the sub-clauses. This makes it easier for
+ derived classes to add new sub-clauses.
+
+2010-08-27 Bernhard Herzog <bh at intevation.de>
+
* mpulsweb/lib/app_globals.py (Globals._init_case_): Add default
implementation of this method. All derived mpuls applications
implement this method in almost the same way. The only difference
Modified: base/trunk/mpulsweb/lib/search.py
===================================================================
--- base/trunk/mpulsweb/lib/search.py 2010-08-27 10:38:05 UTC (rev 3464)
+++ base/trunk/mpulsweb/lib/search.py 2010-08-27 11:01:05 UTC (rev 3465)
@@ -229,19 +229,31 @@
"""
return "TRUE"
+ def get_where_subclauses(self, search, options):
+ """Return a list with the 'where' sub-clauses as strings.
+ This base method calls the get_*_clause methods to gather the
+ commonly used subclauses. Derived classes should extend this
+ method and add new strings to the return value if they need more
+ clauses.
+ """
+ return [
+ self.get_needle_clause(search, options),
+ self.get_status_clause(search, options),
+ self.get_allowed_viewer_clause(search, options),
+ self.get_editor_clause(search, options),
+ self.get_branch_clause(search, options),
+ self.get_dates_clause(search, options),
+ self.get_phases_clause(search, options),
+ self.get_gender_clause(search, options),
+ ]
+
def get_where(self, search, options):
- allowed_viewer = self.get_allowed_viewer_clause(search, options)
- editor = self.get_editor_clause(search, options)
- branch = self.get_branch_clause(search, options)
- phases = self.get_phases_clause(search, options)
- needle_expr = self.get_needle_clause(search, options)
- time_interval = self.get_dates_clause(search, options)
- status_expr = self.get_status_clause(search, options)
- gender = self.get_gender_clause(search, options)
+ """Return the 'where' clause for the search.
+ The clause contains all clauses returned by self.get_where_subclauses
+ combined by AND.
+ """
+ return " AND ".join(self.get_where_subclauses(search, options))
- return " AND ".join((needle_expr, status_expr, allowed_viewer,
- editor, branch, time_interval, phases, gender))
-
def get_order(self, options):
sort_field = options.get('sort_field', "m.id")
sort_order = options.get('sort_order', "desc")
More information about the Mpuls-commits
mailing list