* Added i18n hooks, eg _() and {% trans %} tags around all helpdesk-generated

text to assist with future translation efforts. I've no doubt missed a few.
  Also we don't have a "Change Language" view in here, unsure if this should
  be a helpdesk function or a function of the parent project.
* Updated svn:ignore to ignore .pyc files
* Added new function to replace cursor.dictfetchall() which is available in
  psycopg1 but not psycopg2. New function should work across other database
  systems, but is untested.
This commit is contained in:
Ross Poulton
2008-05-07 09:04:18 +00:00
parent ad05df8dda
commit dfb821336e
25 changed files with 364 additions and 335 deletions

17
lib.py
View File

@ -184,3 +184,20 @@ def bar_chart(data):
chart_url += '&chxl=0:|%s|1:|0|%s' % ('|'.join(column_headings), max) # Axis Label Text
return chart_url
def query_to_dict(results, descriptions):
""" Replacement method for cursor.dictfetchall() as that method no longer
exists in psycopg2, and I'm guessing in other backends too.
Converts the results of a raw SQL query into a list of dictionaries, suitable
for use in templates etc. """
output = []
for data in results:
row = {}
i = 0
for column in descriptions:
row[column[0]] = data[i]
i += 1
output.append(row)
return output