[Mpuls-commits] r5939 - base/trunk/mpulsweb/lib

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Fri Apr 20 15:06:14 CEST 2012


Author: ludwig
Date: 2012-04-20 15:06:14 +0200 (Fri, 20 Apr 2012)
New Revision: 5939

Modified:
   base/trunk/mpulsweb/lib/search.py
Log:
Add Limit and offset possiblity to the search query.


Modified: base/trunk/mpulsweb/lib/search.py
===================================================================
--- base/trunk/mpulsweb/lib/search.py	2012-04-20 10:29:07 UTC (rev 5938)
+++ base/trunk/mpulsweb/lib/search.py	2012-04-20 13:06:14 UTC (rev 5939)
@@ -54,6 +54,7 @@
     JOIN ka_benutzer_tbl b ON m.bearbeiter_id = b.id
     WHERE %(where)s
     %(order)s
+    %(limit)s %(offset)s
     """
 
     SEARCH_FIELDS = """m.id, m.bearbeiter_id, m.phase, %s st.status, st.zugriff, st.id as s_id,
@@ -494,7 +495,22 @@
         sort_order = options.get('sort_order', "desc")
         return self.SEARCH_ORDER % (sort_field, sort_order)
 
+    def get_limit(self, options):
+        limit = options.get('limit', None)
+        limit_str  = ''
+        if limit is not None:
+            limit_str = "LIMIT " + str(limit)
+        return limit_str
 
+    def get_offset(self, options):
+        offset =  options.get('offset', None)
+        if offset is not None:
+            offset_str = "OFFSET " + str(offset)
+        else:
+            offset_str = ""
+        return offset_str
+
+
 class CaseSearch(Search):
 
     VALID_OPTIONS = (Search.VALID_OPTIONS
@@ -520,6 +536,8 @@
         sql_fields['fields'] = self.get_fields(options)
         sql_fields['where'] = self.get_where(options)
         sql_fields['order'] = self.get_order(options)
+        sql_fields['limit'] = self.get_limit(options)
+        sql_fields['offset'] = self.get_offset(options)
 
         SQL = self.SEARCH_QUERY % sql_fields
         return SQL



More information about the Mpuls-commits mailing list