[Zope-dev] type() in DTML or/and in Python Method?

Ava ava@dde974.equipement.gouv.fr
Thu, 25 Nov 1999 17:29:35 +0400


Hello,

I wonder why the builtin function type() is not available, neither from DTML
nor from products like PythonMethod ?
Could the use of such a function be a security problem?

For example, it is impossible to know if a variable holds a list or a tuple
or a string from DTML. I wrote a PythonMethod to do just that:

---------8<----------
return type(value)==type([])
---------8<----------

But that didn't work either. So I ended up writing this PythonMethod:

---------8<----------
try:
    value+[]  # if it throws an exception, value is not of type 'list'
except:
    return 0
return 1
---------8<----------

Sometimes, it is not desirable to write an external method, and in such
circumstances, one feel like doing simple things in a simple manner... :-)

note that i am mostly interested by the security implication caused by the
use of the type function. Solving my "problem" is not important right now.

Regards,

Jephte CLAIN
minf7@educ.univ-reunion.fr

PS: please post any answer to minf7@educ.univ-reunion.fr instead of
ava@dde974.equipement.gouv.fr
Also, I'm not on the list yet, so if you could cc me any answer...