From f93de74671feafbabeed50c80226d57388210d01 Mon Sep 17 00:00:00 2001 From: Sam Ockman Date: Thu, 12 Jul 2012 21:48:55 -0400 Subject: Dictionary code now works --- wqflask/wqflask/dataSharing/SharingInfo.py | 31 ++++++++++++++++++++++------- wqflask/wqflask/templates/data_sharing.html | 6 +++--- 2 files changed, 27 insertions(+), 10 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/dataSharing/SharingInfo.py b/wqflask/wqflask/dataSharing/SharingInfo.py index 1d22d57c..4845b5c8 100755 --- a/wqflask/wqflask/dataSharing/SharingInfo.py +++ b/wqflask/wqflask/dataSharing/SharingInfo.py @@ -60,7 +60,7 @@ class SharingInfo(object): About_Array_Platform, About_Data_Values_Processing, Data_Source_Acknowledge, Progreso """ - InfoRecord = namedtuple('InfoRecord', field_names) + #InfoRecord = namedtuple('InfoRecord', field_names) # We can use string interpolation here cause we own the string sql = """select %s from InfoFiles where """ % (field_names) @@ -75,14 +75,18 @@ class SharingInfo(object): info = cursor.fetchone() print("432 info:", info) print("type(info):", type(info)) - info = InfoRecord._make(info) - - print("q888 info.Title:", info.Title) + #info = InfoRecord._make(info) + info = todict(field_names, info) + # We need to edit info so we convert it to a dict... + #info = info._asdict() + print("q888 info.Title:", info['Title']) print("info type is:", type(info)) - new_about_cases = unicode(info.About_Cases, "utf-8") - print("new_about_cases is:", new_about_cases) - info.About_Cases = new_about_cases + #new_about_cases = unicode(info.About_Cases, "utf-8") + #print("new_about_cases is:", new_about_cases) + + + #info['About_Cases'] = unicode(info['About_Cases'], "utf-8") # fetch datasets file list try: @@ -130,3 +134,16 @@ class SharingInfo(object): print("333 keys:", pf(info)) return info, htmlfilelist #return SharingBody.sharinginfo_body_string % (info[31], info[32], infoupdate, info[32], info[1], info[3], info[30], info[4], info[27], info[33], info[2], info[23], info[26], info[11], info[15], info[16], info[18], info[19], info[20], info[21], info[22], info[13], info[12], info[14], info[14], htmlfilelist, info[6], info[35], info[36], info[37], info[38], info[39], info[40], info[5], info[7], info[8], info[9], info[10], info[17], info[24]) + + +def todict(fields, values): + """Converts sql results into a user friendly dictionary""" + new_dict = {} + fields = fields.split(",") + for counter, field in enumerate(fields): + field = field.strip() + value = values[counter] + if isinstance(value, str): + value = unicode(value, "utf-8") + new_dict[field] = value + return new_dict diff --git a/wqflask/wqflask/templates/data_sharing.html b/wqflask/wqflask/templates/data_sharing.html index a6e044b4..4e92106a 100644 --- a/wqflask/wqflask/templates/data_sharing.html +++ b/wqflask/wqflask/templates/data_sharing.html @@ -56,11 +56,11 @@

- + - + - + -- cgit v1.2.3
Summary:
{{ info.Summary }}

{{ info.Summary | safe}}

About the cases used to generate this set of data:
{{ info.About_Cases | safe}}
{{ info.About_Cases | safe}}
About the tissue used to generate this set of data:
{{ info.About_Tissue }}
{{ info.About_Tissue | safe }}
About downloading this data set:

All data links (right-most column above) will be made active as sooon as the global analysis of these data by the Consortium has been accepted for publication. Please see text on Data Sharing Policies, and Conditions and Limitations, and Contacts. Following publication, download a summary text file or Excel file of the PDNN probe set data. Contact RW Williams regarding data access problems.