[ZPT] Re: Select/Repeat Syntax

Philip Kilner phil at xfr.co.uk
Tue Aug 3 03:51:20 EDT 2004


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>

...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!!!

-- 

Regards,

PhilK

Email: phil at xfr.co.uk / Voicemail & Facsimile: 07092 070518

"The lyf so short, the craft so long to learne" - Chaucer



More information about the ZPT mailing list