Hi everyone, I cannot figure out how to do something the Zope way(TM). Basically, PHP lets you call a query and act on it conditionally, e.g. "if the query returns data do A, if not then do B". How is this done best within Zope? For example, I got really used to returning a recordset (query) as an HTML table. But only IF the recordset returned more than 0 rows. If the query had an empty result, then I would instead print "<p>No records found.</p>" or something like that. I know there's a better and easier way in Zope, I just don't know how -;^>= Can someone kindly point me in the right direction? -- Mitch Pirtle Corporate Security Officer Kühne & Nagel Management AG Tel: +41 1 786 96 45 Fax: +41 1 786 95 95
Hi. Thats easy in Zope too (not to say "its easier" ...): <dtml-in myZSQLQuery> here state your result <dtml-else> Sorry, no data returned </dtml-in> Watch out you "Help!" link in the Zope Management Interface, where the DTML Reference for "dtml-in" gives you a lot of answers ... Greetings Christian On Thu, Mar 07, 2002 at 10:44:43AM +0100, Mitch Pirtle wrote:
Hi everyone,
I cannot figure out how to do something the Zope way(TM). Basically, PHP lets you call a query and act on it conditionally, e.g. "if the query returns data do A, if not then do B". How is this done best within Zope?
For example, I got really used to returning a recordset (query) as an HTML table. But only IF the recordset returned more than 0 rows. If the query had an empty result, then I would instead print "<p>No records found.</p>" or something like that.
I know there's a better and easier way in Zope, I just don't know how -;^>= Can someone kindly point me in the right direction?
--
Mitch Pirtle Corporate Security Officer Kühne & Nagel Management AG Tel: +41 1 786 96 45 Fax: +41 1 786 95 95
_______________________________________________ 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 )
-- Christian Theune - ct@gocept.com gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981 reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])
Thanks for the quick response. This doesn't solve my problem, though. Where do you conditionally put the HTML for the table (that does not belong in the loop)? So (for example) I really want to: if(query returned results) print <table>, header row once, not in loop *** NOW loop on the query results for each <TR> *** print </table> once, not in loop else print "<p>Sucks to be you, homey.</p>\n" // NO TABLE endif I am not into doing this as a python script, and then passing every query to it for HTML formatting - each row may have arbitrary links added based on either the query or calling method, so it cannot be reused as a generic object. Or am I approaching it the wrong way? On Thu, 2002-03-07 at 09:58, Christian Theune wrote:
Hi.
Thats easy in Zope too (not to say "its easier" ...):
<dtml-in myZSQLQuery>
here state your result
<dtml-else>
Sorry, no data returned
</dtml-in>
Watch out you "Help!" link in the Zope Management Interface, where the DTML Reference for "dtml-in" gives you a lot of answers ...
Greetings
Christian
On Thu, Mar 07, 2002 at 10:44:43AM +0100, Mitch Pirtle wrote:
Hi everyone,
I cannot figure out how to do something the Zope way(TM). Basically, PHP lets you call a query and act on it conditionally, e.g. "if the query returns data do A, if not then do B". How is this done best within Zope?
For example, I got really used to returning a recordset (query) as an HTML table. But only IF the recordset returned more than 0 rows. If the query had an empty result, then I would instead print "<p>No records found.</p>" or something like that.
I know there's a better and easier way in Zope, I just don't know how -;^>= Can someone kindly point me in the right direction?
--
Mitch Pirtle Corporate Security Officer Kühne & Nagel Management AG Tel: +41 1 786 96 45 Fax: +41 1 786 95 95
_______________________________________________ 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 )
-- Christian Theune - ct@gocept.com gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981
reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])
_______________________________________________ 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 ) --
Mitch Pirtle Corporate Security Officer Kühne & Nagel Management AG Tel: +41 1 786 96 45 Fax: +41 1 786 95 95
Hi. So you are using DTML (that implied your topic, ai?): one solution is: <dtml-in mySQLMethod> <dtml-if sequence-start> <table> <tr><th>first header</th><th>second header ....</tr> </dtml-if> <tr><td><dtml-var first-item></td><td><dtml-var second-item> ...</tr> <dtml-if sequence-end> </table> </dtml-if> <dtml-else> No data found </dtml-in> btw: try using ZPT instead of dtml ... :) On Thu, Mar 07, 2002 at 11:25:22AM +0100, Mitch Pirtle wrote:
Thanks for the quick response. This doesn't solve my problem, though. Where do you conditionally put the HTML for the table (that does not belong in the loop)?
So (for example) I really want to:
if(query returned results) print <table>, header row once, not in loop *** NOW loop on the query results for each <TR> *** print </table> once, not in loop else print "<p>Sucks to be you, homey.</p>\n" // NO TABLE endif
I am not into doing this as a python script, and then passing every query to it for HTML formatting - each row may have arbitrary links added based on either the query or calling method, so it cannot be reused as a generic object.
Or am I approaching it the wrong way?
On Thu, 2002-03-07 at 09:58, Christian Theune wrote:
Hi.
Thats easy in Zope too (not to say "its easier" ...):
<dtml-in myZSQLQuery>
here state your result
<dtml-else>
Sorry, no data returned
</dtml-in>
Watch out you "Help!" link in the Zope Management Interface, where the DTML Reference for "dtml-in" gives you a lot of answers ...
Greetings
Christian
On Thu, Mar 07, 2002 at 10:44:43AM +0100, Mitch Pirtle wrote:
Hi everyone,
I cannot figure out how to do something the Zope way(TM). Basically, PHP lets you call a query and act on it conditionally, e.g. "if the query returns data do A, if not then do B". How is this done best within Zope?
For example, I got really used to returning a recordset (query) as an HTML table. But only IF the recordset returned more than 0 rows. If the query had an empty result, then I would instead print "<p>No records found.</p>" or something like that.
I know there's a better and easier way in Zope, I just don't know how -;^>= Can someone kindly point me in the right direction?
--
Mitch Pirtle Corporate Security Officer Kühne & Nagel Management AG Tel: +41 1 786 96 45 Fax: +41 1 786 95 95
_______________________________________________ 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 )
-- Christian Theune - ct@gocept.com gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981
reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])
_______________________________________________ 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 ) --
Mitch Pirtle Corporate Security Officer Kühne & Nagel Management AG Tel: +41 1 786 96 45 Fax: +41 1 786 95 95
_______________________________________________ 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 )
-- Christian Theune - ct@gocept.com gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981 reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])
On 7 Mar 2002, Mitch Pirtle wrote:
Thanks for the quick response. This doesn't solve my problem, though. Where do you conditionally put the HTML for the table (that does not belong in the loop)?
So (for example) I really want to:
if(query returned results) print <table>, header row once, not in loop *** NOW loop on the query results for each <TR> *** print </table> once, not in loop else print "<p>Sucks to be you, homey.</p>\n" // NO TABLE endif
I am not into doing this as a python script, and then passing every query to it for HTML formatting - each row may have arbitrary links added based on either the query or calling method, so it cannot be reused as a generic object.
Or am I approaching it the wrong way?
One way: <dtml-let results="theQuery()"> <dtml-if results> <table>...blah blah blah <dtml-in results> <tr>...</tr> </dtml-in> </table> <dtml-else> Noting. Does that just suck? </dtml-if> </dtml-let> Another way: <dtml-in "theQuery()"> <dtml-if sequence-start> <table> </dtml-if> <tr>...</tr> <dtml-if sequence-end> </table> </dtml-if> <dtml-else> Nothing. What a sad thing. </dtml-in> -- Joel BURTON | joel@joelburton.com | joelburton.com | aim: wjoelburton Independent Knowledge Management Consultant
participants (3)
-
Christian Theune -
Joel Burton -
Mitch Pirtle