hi guys, i am very new to zope . i executed a query that will print 25 column. i don't want to hardcode the column name.i am getting the column name by below python script test.py rec = context.DbQuery1() print "names: ", rec.names(), "\n" return rec.names() using the column name i want to print the corresponding data. <dtml-in test.py> <dtml-in DbQuery1 size=10 start=query_start> <dtml-let names="_.getitem('sequence-item')"> <dtml-var names> </dtml-let> </dtml-in> </dtml-in> but it's printing the object. <r instance at 02FF5E50> <r instance at 02FF5730> <r instance at 02FF5200> <r instance at 02FF59A0> <r instance at 02FF54F0> <r instance at 02FF5B60> <r instance at 02FF5180> <r instance at 02FF64A0> <r instance at 02FF68B0> <r instance at 02FF6500> can any one help me . regards, S.Sudhakar Sys Admin, Progammer Mindscape Computing (P) Ltd., Bangalore
You have two problems. We don't know which one you've solved. Do one thing at a time: <dtml-in test.py> <dtml-in DbQuery1 size=10 start=query_start> <dtml-var sequence-item> </dtml-in> </dtml-in> If that works, your Z SQL methods problem are solved. Nextly, copy one of the printed sequence items and try (Independently): <dtml-var "_.getitem('one of the names')"> Does that help. Besides, it think there's a difference in <dtml-let names="_.getitem('sequence-item')"> and <dtml-let names="_.getitem(_['sequence-item'])"> Both will "work" but it depends on what you want to do. Cheers, Peter ----- Original Message ----- From: "sudhakar" <sudhakar@mindscapecomputing.com> To: <zope@zope.org> Sent: Tuesday, August 07, 2001 6:40 AM Subject: [Zope] Regarding Mysql Query
hi guys,
i am very new to zope . i executed a query that will print 25 column. i don't want to hardcode the column name.i am getting the column name by below python script
test.py rec = context.DbQuery1() print "names: ", rec.names(), "\n" return rec.names()
using the column name i want to print the corresponding data.
<dtml-in test.py> <dtml-in DbQuery1 size=10 start=query_start> <dtml-let names="_.getitem('sequence-item')"> <dtml-var names> </dtml-let> </dtml-in> </dtml-in>
but it's printing the object.
<r instance at 02FF5E50> <r instance at 02FF5730> <r instance at 02FF5200> <r instance at 02FF59A0> <r instance at 02FF54F0> <r instance at 02FF5B60> <r instance at 02FF5180> <r instance at 02FF64A0> <r instance at 02FF68B0> <r instance at 02FF6500>
can any one help me .
regards, S.Sudhakar Sys Admin, Progammer Mindscape Computing (P) Ltd., Bangalore
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
sudhakar writes:
... <dtml-in test.py> <dtml-in DbQuery1 size=10 start=query_start> <dtml-let names="_.getitem('sequence-item')"> .... but it's printing the object. <r instance at 02FF5E50> Your code is a bit confused...
You have a nested "dtml-in": "sequence-item" refers to the innermost "dtml-in", i.e. "DbQuery1". Therefore, "_.getitem('sequence-item')" is one row of your result, an "r instance", as you can see. I would do it like this (avoidung the Python Script and the second query execution): <dtml-let result__=DbQuery1 names__="result__.names()"> <dtml-in result__ size=20 start=query_start> <dtml-if sequence-start> <table> <tr><dtml-in names__><th>&dtml-sequence-item;</th></dtml-in></tr> </dtml-if> <tr><dtml-in names__><td><dtml-var "_['sequence-item']" html_quote></td></dtml-in</tr> <dtml-if sequence-end> </table> </dtml-if> </dtml-in> </dtml-let> Dieter
participants (3)
-
Dieter Maurer -
Peter Bengtsson -
sudhakar