Author: eallen
Date: 2008-10-31 17:25:52 -0400 (Fri, 31 Oct 2008)
New Revision: 2721
Modified:
mgmt/trunk/cumin/python/wooly/tables.py
Log:
Refactor the code to convert cursor tuples to lists of dictionaries for use by model
during an ajax call.
Modified: mgmt/trunk/cumin/python/wooly/tables.py
===================================================================
--- mgmt/trunk/cumin/python/wooly/tables.py 2008-10-31 21:22:45 UTC (rev 2720)
+++ mgmt/trunk/cumin/python/wooly/tables.py 2008-10-31 21:25:52 UTC (rev 2721)
@@ -192,9 +192,9 @@
def render_sql_orderby(self, session, *args):
scol = self.get_selected_column(session)
+ if scol:
+ return scol.get_orderby_sql(session)
- return scol.get_orderby_sql(session)
-
def render_sql_limit(self, session, *args):
return None
@@ -288,21 +288,23 @@
sql = " and ".join(["%s %s" % (select, where),
find_where])
try:
cursor.execute(sql, find_values)
-
- cols = [spec[0] for spec in cursor.description]
- row = dict()
- rows = list()
-
- for tuple in cursor:
- for col, datum in zip(cols, tuple):
- row[col] = datum
-
- rows.append(row)
-
- return rows
+ return self.cursor_to_rows(cursor)
except:
pass
+ def cursor_to_rows(self, cursor):
+ cols = [spec[0] for spec in cursor.description]
+ rows = list()
+
+ for tuple in cursor:
+ row = dict()
+ for col, datum in zip(cols, tuple):
+ row[col] = datum
+
+ rows.append(row)
+
+ return rows
+
class SqlTableColumn(ItemTableColumn):
# XXX to be consistent with similar methods, rename to
# get_sql_order_by
Show replies by date