Apologies, hit the button without a subject.
I have an dict which is the result of a SQLAlchemy query of a PG database:
sqla_p1_mails = c.execute("select e.subject, e.sender_addr, e.date,
e.sz_bytes, e.nbr_attach, e.id from email e where e.project_id = %d;" %
(pr_id))
p1_mails = sqla_p1_mails.fetchall()
This query works fine and produces p1_emails which can be indexed by # or
query string:
In [5]: p1_mails[1]["subject"]
Out[5]: '[BiO BB] Re: [Bioperl-l] Tool to mutate DNA sequence'
In [6]: p1_mails[1][0]
Out[6]: '[BiO BB] Re: [Bioperl-l] Tool to mutate DNA sequence'
The array index goes like [row] ["subject" || "sender_addr" etc], as can be
seen from the query.
I'd like to use the DataGrid to display it in a web page but I can't figure
out how to define my datagrid so that it iterates correctly.
the excllent lucasmanual:
<
http://lucasmanual.com/mywiki/TurboGears#head-ba91d42a569b347f9886341db15e317681037816
>
suggests assign_mapping, but that's depreciated and I'm not sure it would
work anyway.
It seems that I need to pivot the dict to provide the correct data structure
for Datagrid? That seems counter-intuitive for a widget that should be able
to present data in "DB-query order" ie:
In [7]: p1_mails[1]
Out[7]: ('[BiO BB] Re: [Bioperl-l] Tool to mutate DNA sequence', 'Harry Mann
<[EMAIL PROTECTED]>', datetime.datetime(2006, 2, 9, 3, 15, 28,
tzinfo=<psycopg2.tz.FixedOffsetTimezone object at 0x8e4858c>), 677, 1, 255)
I tried this:
mail_form = DataGrid(fields=[
('Subj', 'p1_mails[0][0]'),
('From', 'p1_mails[0][1]'),
('Date', 'p1_mails[0][2]'),
('Size', 'p1_mails[0][3]'),
('Att', 'p1_mails[0][4]'),
])
but unsuprisingly, it failed. What is the better way?
TIA!
Harry
--
Harry Mangalam - Research Computing, NACS, E2148, Engineering Gateway,
UC Irvine 92697 949 824 0084(o), 949 285 4487(c)
--
[A Nation of Sheep breeds a Government of Wolves.
Edward R. Murrow]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---