[Zope] calling an Python builtin function

Duncan Booth duncan@rcp.co.uk
Thu, 25 May 2000 12:47:58 +0000


> Beside of this, is there a way to test if foo is a string or a
> sequence or whatever ??
apart from changing your form to force the list type, you could try 
(untested code):

<dtml-let checkbox="(checkbox==_.str(checkbox) and [checkbox] 
or checkbox">
...
</dtml-let>

There is no easy way to check whether a value in Zope is a list, 
tuple, or integer, but there is an easy way to check whether it is a 
string since strings are the only type left unchanged by the str 
function.

More advanced type recognition generally requires trying various 
things and catching the exceptions that are raised. I have put a 
PythonMethod that does general type recognition in a HowTo at 
http://www.zope.org/Members/Duncan/RecogniseTypes


-- 
Duncan Booth                                             duncan@dales.rmplc.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan