[ZPT] Re: Select/Repeat Syntax

Godefroid Chapelle gotcha at bubblenet.be
Tue Aug 3 03:56:20 EDT 2004


Philip Kilner wrote:

> Hi Godefroid,
> 
> Godefroid Chapelle wrote:
> 
>>> FWIW, I'm currently wrestling with: -
>>>
>>> <span tal:replace="python: 
>>> result.CurrentDate.strftime('%d/%m/%Y')">Date</span>
>>>
>>> ...which fails (on strftime) when CurrentDate is null - but I can't 
>>> for the life of me figure out how to make the evaluation dependant 
>>> upon the date being populated.
>>
>>
>>
>> <span tal:define="curDate result/CurrentDate"
>>       tal:replace="python:test(curDate is None, 'your default string',
>>                    curDate.strftime('%d/%m/%Y'))">Date</span>
>>
>> should do it...
>>
> 
> Thanks - in fact I'd just got to: -
> 
> <span tal:condition="result/CurrentDate" tal:replace="python: 
> result.CurrentDate.strftime('%d/%m/%Y')">CtrCandRef</span>
> 
In case you want to avoid output on null value, this way is the best !

> ...which seems to work (I've no default - the value comes from a dB, and 
> may be null, which is the case I was struggling with.
> 
> I've been working all night so I'm a bit frazzled - for some reason I 
> thought I should be able to do it in a single statement rather tan 
> wrapping the formatted version up in a condition - D'Oh!
> 
> More coffee!!!
> 


-- 
Godefroid Chapelle (aka __gotcha)                http://bubblenet.be



More information about the ZPT mailing list