Is there any way to do data type checking in dtml-if, for example to check that a variable is an integer? regards garry
<dtml-try> <dtml-if "_.int(variable) = variable"> Variable is integer <dtml-else> Variable is not integer </dtml-if> <dtml-except> Variable is not number </dtml-try> ----- Original Message ----- From: "Garry Saddington" <garry@schoolteachers.co.uk>
Is there any way to do data type checking in dtml-if, for example to check that a variable is an integer?
Sorry, syntax error: <dtml-if "_.int(variable) == variable"> ---------------------------^
----- Original Message ----- From: "Jaroslav Lukesh" <lukesh@seznam.cz> To: "Garry Saddington" <garry@schoolteachers.co.uk>; <zope@zope.org> Sent: Monday, April 14, 2008 4:48 PM Subject: Re: [Zope] type checking
<dtml-try> <dtml-if "_.int(variable) = variable"> Variable is integer <dtml-else> Variable is not integer </dtml-if> <dtml-except> Variable is not number </dtml-try>
The 'same_type' function may be what you are looking for: <dtml-if "_.same_type(a,[])"> a is a list <dtml-elif "_.same_type(a,{})"> a is a dict <dtml-elif etc> </dtml-if> Jonathan
Jaroslav Lukesh wrote:
<dtml-try> <dtml-if "_.int(variable) = variable"> Variable is integer <dtml-else> Variable is not integer </dtml-if> <dtml-except> Variable is not number </dtml-try>
Argggh! My eyes! They bleeeeeed! Please dear god just use a python script or external method... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (4)
-
Chris Withers -
Garry Saddington -
Jaroslav Lukesh -
Jonathan