[Zope] How can I call a ZSQL method in <dtml-if> tag?

Joel Burton joel@joelburton.com
Thu, 21 Feb 2002 00:05:12 -0500 (EST)


On Wed, 20 Feb 2002, Jin Chen wrote:

You want   expr="CountCrew() ==1"

Without the parens, you're looking at the object, not the result of the
object.

HTH.

> Hi there,
>
> I am a newer to zope application. I met a problem of calling a ZQSL method
> in the DTML if tag. Here is the example:
>
> I have a ZSQL method called "CountCrew" which has no input parameter. the
> query is: select count(*) from crew
>
> 1. I test it looks good on the ZSQL method "CountCrew" page. If the table
> crew has no data, it returns 0, if has one record, it retuens 1...
>
> 2. I call this ZSQL method in a DTML method, code likes:
>
> <dtml-if expr="CountCrew == 1">
> <dtml-call "AddCrew(ptime=time1,name=name2,pemail=email1)">
> <dtml-else>
> <dtml-var Error>
> </dtml-if>
>
> But the <dtml-if ..> test is false and show the Error message no
> mater there is one crew or none in the crew table.
>
> If I test it like this:
> <dtml-if "CountCrew">//or <dtml-if expr="CountCrew">
> <dtml-call "AddCrew(ptime=time1,name=name2,pemail=email1)">
> <dtml-else>
> <dtml-var Error>
> </dtml-if>
> the <dtml-if ..> test is always true and add the record no mater there is
> none  or one crew in the crew table.
>
>
> You know, I want to add the record in the crew table only if there is at
> least one crew exist in the crew table.
>
> I don't know what's wrong with calling the ZSQL method in DTML if tag.
> Please give me any advice if you have time.
>
> Thanks in advance!
>
> Jean
>
> _______________________________________
> Jean Chen
>
> The Nautilus Institute
> 125 University Avenue
> Berkeley, CA 94710-1616 USA
> (510) 295-6113 * Fax: (510) 295-6130
> jchen@nautilus.org
> http://www.nautilus.org
>
> _______________________________________________
> 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 )
>

-- 

Joel BURTON  |  joel@joelburton.com  |  joelburton.com  |  aim: wjoelburton
Independent Knowledge Management Consultant