Pascal De Oliveira wrote at 2005-11-11 12:59 +0100: > ... >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') ?
Keep in mind that "test" is a standard Python function. Any standard Python function evaluates all of its arguments before the function is called. That's why the "false" part is evaluated even though the "condition" is true. Use Python's "and" and "or" operators to get real conditional evaluation. Rumours say that Python will finally (probably with Python 2.5) grow a conditional operator -- lately overdue... Then the need for "test" and the "and/or" hackery will end... -- Dieter _______________________________________________ ZPT mailing list ZPT@zope.org http://mail.zope.org/mailman/listinfo/zpt