[ZPT] Bug in ZPT ?

Pascal De Oliveira pascal.deoliveira at gmail.com
Fri Nov 11 06:59:54 EST 2005


I found a strange thing in ZPT and I'd like you to confirm whether the bug
is in ZPT or in my understanding ...
I'd like to put in the 'value' attribute of an input tag a value depending
on the content of a member variable.

If I use the following code :
<input class="string" type="text" name="last" tal:attributes="value
python:test(request['member']=='NEW','new',request['member'])">
everything is OK and I get the following results :
[path]?member=NEW --> new
[path]?member=member_00000000 --> member_00000000

but if I use the following code :
<input class="string" type="text" name="last" tal:attributes="value
python:test(request['member']=='NEW','new',context[request['member']].LastName)">
I get the following results which are wrong :
[path]?member=NEW --> Error Type: KeyError / Error Value: 'NEW'
[path]?member=member_00000000 --> DE OLIVEIRA

I don't understand why the 'true' part of the test() generated an error
while I have just changed the 'false' part of it (and this 'false' part is
valid as I get a good result when 'member' is not 'NEW') ?

So, is it a bug and if so, is there a workaround ?
Thank you for your help,

pascal de oliveira
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zpt/attachments/20051111/9ba269a5/attachment.htm


More information about the ZPT mailing list