type() in DTML or/and in Python Method?
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...
Ava wrote:
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?
Yep. Beleive it or not, on certain Extension Methods type() returns an executable object which should not be exposed in Zope. I've suggested adding a nice safe same_type(a,b) function to the namespace, but got no response. I'll go file it with the Collector now. Cheers, Evan @ 4-am
participants (2)
-
Ava -
Evan Simpson