[ZPT] tal:define and tal:condition nesting

Sebastian Stark seb@todesplanet.de
Thu, 10 Oct 2002 19:24:32 +0200


I'm currently trying to do a simple quiz application for my bands
homepage.

There's a template called "quiz.html" that contains the questions
(simple html form with radio buttons). The form tag looks like this:

<form action="quiz.html" method="post">
[...]
</form>

So the quiz.html will evaluate itself using TAL and that's where my
problem starts.

The questions look like this (this is a sample, of course):

<b>How much is 2 times 2?</b><br>
<input type="radio" name="q1" value="2"> 2
<input type="radio" name="q1" value="3"> 3
<input type="radio" name="q1" value="4"> 4
<p tal:condition="request/form/q1 | nothing">
  <span tal:define="r request/form/q1"
        tal:condition="python:r==4">
        "4" is correct!
  </span>
</p>

As you can see, I'd like to have a line telling the user if the answer
was correct right after the question.

If there is a parameter "q1" (=user answered the question) its value is
assigned to the variable "r". "r" must be 4 and confirmation appears.
Wrong answer -> no confirmation. I think it's clear what I'm trying to
achieve.

Of course it doesn't work. Can someone enlighten me why?

I'm using ZPT 1.4.0 and Zope Version (Zope 2.5.1 (source release, python
2.1, linux2), python 2.1.3, linux2)


Thanks in advance,
Sebastian

-- 
Free your mind and your ass will follow -- http://www.funkaffair.de