[Zope] Funny problem with DTML, please help!

pan@aster.net pan@aster.net
20 Apr 1999 08:48:38 +0300


I managed to get it to work.  It seems that the variable first
mentioned in

<!--#call "REQUEST.set('count_yes', 0)"-->

gives an error when used in:

     <!--#if "answer == 'Y'"-->
       <!--#call "REQUEST.set('count_yes', REQUEST['count_yes']+cnt)"-->
     <!--#/if-->

and not in

     <!--#if "answer == 'Y'"-->
       <!--#call "REQUEST.set('count_yes', cnt)"-->
     <!--#/if-->

The rest of the variables can be incremented without problems.  This
is really strange?!

I have it now working as:

<!--#comment-->
Calculate the vote percentage
<!--#/comment->

<!--#call "REQUEST.set('count_dummy', 0)"-->
<!--#call "REQUEST.set('count_yes', 0)"-->
<!--#call "REQUEST.set('count_no', 0)"-->
<!--#call "REQUEST.set('count_all', 0)"-->

<!--#in sql_distinct_votes-->
  <!--#if "cnt == 1"-->
    <!--#if "answer == 'Y'"-->
      <!--#call "REQUEST.set('count_yes', REQUEST['count_yes']+cnt)"-->
    <!--#/if-->
    <!--#if "answer == 'N'"-->
      <!--#call "REQUEST.set('count_no', REQUEST['count_no']+cnt)"-->
    <!--#/if-->
    <!--#call "REQUEST.set('count_all', REQUEST['count_all']+cnt)"-->
  <!--#/if-->
<!--#/in-->

<!--#comment-->
Now display the results
<!--#/comment-->

<h2> Total : <!--#var "REQUEST['count_all']"--> votes</h2>

<ul> 
  <li>Yes : <!--#var "REQUEST['count_yes']"--> votes (<!--#var "_.round(((REQUEST['count_yes']+0.0)/REQUEST['count_all'])*100,1)"-->%)</li>
  <li>No : <!--#var "REQUEST['count_no']"--> votes (<!--#var "_.round(((REQUEST['count_no']+0.0)/REQUEST['count_all'])*100,1)"-->%)</li>
</ul>

pan@aster.net writes:

> Hi guys,
> 
> I hope someone can help me with this one, because it's almost driving
> me crazy :-)
> 
> The following code fails with an error for count_yes:
> 
> <!--#comment-->
> Calculate the vote percentage
> <!--#/comment->
> 
> <!--#call "REQUEST.set('count_yes', 0)"-->
> <!--#call "REQUEST.set('count_no', 0)"-->
> <!--#call "REQUEST.set('count_all', 0)"-->
> 
> <!--#in sql_distinct_votes-->
>   <!--#if "cnt == 1"-->
>     <!--#if "answer == 'Y'"-->
>       <!--#call "REQUEST.set('count_yes', REQUEST['count_yes']+cnt)"-->
>     <!--#/if-->
>     <!--#if "answer == 'N'"-->
>       <!--#call "REQUEST.set('count_no', REQUEST['count_no']+cnt)"-->
>     <!--#/if-->
>     <!--#call "REQUEST.set('count_all', REQUEST['count_all']+cnt)"-->
>   <!--#/if-->
> <!--#/in-->
> 
> <!--#comment-->
> Now display the results
> <!--#/comment-->
> 
> <h2> Total : <!--#var "REQUEST['count_all']"--> votes</h2>
> 
> <ul> 
>   <li>Yes : <!--#var "REQUEST['count_yes']"--> votes (<!--#var "_.round(((REQUEST['count_yes']+0.0)/REQUEST['count_all'])*100,1)"-->%)</li>
>   <li>No : <!--#var "REQUEST['count_no']"--> votes (<!--#var "_.round(((REQUEST['count_no']+0.0)/REQUEST['count_all'])*100,1)"-->%)</li>
> </ul>
> 
> 
> When I change
> 
>       <!--#call "REQUEST.set('count_yes', REQUEST['count_yes']+cnt)"-->
> 
> to 
> 
>       <!--#call "REQUEST.set('count_yes', cnt)"-->
> 
> it works as expected, no errors, but that's not what I want :-( I've
> tried, superstitiously, to change count_yes to several other things,
> but no luck.  It always gives me an error for the vairable I
> substitute for count_yes.  The strangest thing is that the same code
> works for count_no and count_all ?!?
> 
> Any ideas?
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://www.zope.org/mailman/listinfo/zope
> 
> (For developer-specific issues, use the companion list,
> zope-dev@zope.org - http://www.zope.org/mailman/listinfo/zope-dev )