[ZPT] how do I test the existence of a variable?

seb bacon seb@jamkit.com
21 Mar 2002 11:56:56 +0000


On Thu, 2002-03-21 at 11:44, Thomas Olsen wrote:
> On Thursday 21 March 2002 12:23, you wrote:
> >   <b tal:condition="exists:currentnamespace/foo">Foo exists</b>
> 
> Not sure but cant you do:
> 
> <b tal:condition="exists:foo">Foo exists</b>

Thanks for the pointer, of course you are right.  However, in trying to
reduce it to a simple example, I phrased my problem completely wrongly. 
I'm trying to set a default value in an expression.  If I test for it
then I have to branch the code, which I find a bit messy in ZPT.  What
I'm trying to do is more like:

  <span tal:define="thing python:namespace.get('thing', 'defaultval')">

Cheers,

seb