[Mpuls-commits] r3459 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Aug 26 18:29:28 CEST 2010


Author: bh
Date: 2010-08-26 18:29:27 +0200 (Thu, 26 Aug 2010)
New Revision: 3459

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/search.py
Log:
* mpulsweb/lib/search.py (SEARCH_QUERY, SEARCH_FIELDS)
(SEARCH_ORDER): Removed.  They're defined in the Search class now
(Search.SEARCH_QUERY, Search.SEARCH_FIELDS, Search.SEARCH_ORDER):
New.  Move here from module level.
(CaseSearch.get_fields, CaseSearch.get_order)
(CaseSearch._build_sql): Access the moved string constants through
the instance


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-08-26 14:31:30 UTC (rev 3458)
+++ base/trunk/ChangeLog	2010-08-26 16:29:27 UTC (rev 3459)
@@ -1,5 +1,15 @@
 2010-08-26  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/lib/search.py (SEARCH_QUERY, SEARCH_FIELDS)
+	(SEARCH_ORDER): Removed.  They're defined in the Search class now
+	(Search.SEARCH_QUERY, Search.SEARCH_FIELDS, Search.SEARCH_ORDER):
+	New.  Move here from module level.
+	(CaseSearch.get_fields, CaseSearch.get_order)
+	(CaseSearch._build_sql): Access the moved string constants through
+	the instance
+
+2010-08-26  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/templates/evaluation/evaluate_adele.mako: Removed.
 	It's not used anymore and its functionality is handled by
 	mpulsweb/templates/evaluation/evaluate.mako

Modified: base/trunk/mpulsweb/lib/search.py
===================================================================
--- base/trunk/mpulsweb/lib/search.py	2010-08-26 14:31:30 UTC (rev 3458)
+++ base/trunk/mpulsweb/lib/search.py	2010-08-26 16:29:27 UTC (rev 3459)
@@ -11,19 +11,6 @@
 
 
 SAVE_SEARCH = re.compile(r'[^\w:;\-\. ]', re.UNICODE)
-SEARCH_QUERY = """
-    SELECT %(fields)s
-    FROM master_tbl_view m
-    JOIN ka_status_tbl_view st ON
-    m.id = st.master_id
-    JOIN ka_benutzer_tbl b ON
-    m.bearbeiter_id = b.id
-    WHERE %(where)s
-    %(order)s
-"""
-SEARCH_FIELDS = """m.id, m.phase, %s st.status, st.zugriff, st.id as s_id,
-ARRAY(SELECT tag_id FROM nm_tags_cases_view WHERE case_id = m.id) AS tags """
-SEARCH_ORDER = """ORDER BY %s %s"""
 
 
 log = logging.getLogger(__name__)
@@ -33,6 +20,22 @@
 
     VALID_OPTIONS = ('state', 'phase')
 
+    SEARCH_QUERY = """
+    SELECT %(fields)s
+    FROM master_tbl_view m
+    JOIN ka_status_tbl_view st ON m.id = st.master_id
+    JOIN ka_benutzer_tbl b ON m.bearbeiter_id = b.id
+    WHERE %(where)s
+    %(order)s
+    """
+
+    SEARCH_FIELDS = """m.id, m.phase, %s st.status, st.zugriff, st.id as s_id,
+    ARRAY(SELECT tag_id FROM nm_tags_cases_view WHERE case_id = m.id) AS tags
+    """
+
+    SEARCH_ORDER = """ORDER BY %s %s"""
+
+
     def __init__(self):
         pass
 
@@ -110,7 +113,7 @@
         retrieve = ", ".join("m." + field for field in self.retrieve_fields)
         if retrieve:
             retrieve = "%s," % retrieve
-        return SEARCH_FIELDS % retrieve
+        return self.SEARCH_FIELDS % retrieve
 
     def get_allowed_viewer_clause(self, search, options):
         """Return the search condition that selects based on owner or standin.
@@ -242,7 +245,7 @@
     def get_order(self, options):
         sort_field = options.get('sort_field', "m.id")
         sort_order = options.get('sort_order', "desc")
-        return SEARCH_ORDER % (sort_field, sort_order)
+        return self.SEARCH_ORDER % (sort_field, sort_order)
 
     def _build_sql(self, search, options):
         sql_fields = {}
@@ -250,7 +253,7 @@
         sql_fields['where'] = self.get_where(search, options)
         sql_fields['order'] = self.get_order(options)
 
-        SQL = SEARCH_QUERY % sql_fields
+        SQL = self.SEARCH_QUERY % sql_fields
         return SQL
 
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:



More information about the Mpuls-commits mailing list