[Zope-dev] Asking for the type of a variable

Christopher Petrilli petrilli@digicool.com
Wed, 10 Nov 1999 08:28:34 -0500


On 11/9/99 4:55 PM, David S. Harrison at dsh@magma-da.com wrote:

> 
> It looks like I need to ask for the type of a python variable from DTML.
> So far, I haven't been able to get this to work:
> 
> <dtml-if "type(TAG)==type('x')">
> 
> I am trying to see if the TAG variable is a string.  Zope complains about
> "type".  I tried using the special name space:
> 
> <dtml-if "_.type(TAG)==_.type('x')">

BTW, the reason 'type' isn't in the name space is security related and has
to do with what 'type' returns (the base abstract class in Python), and the
ability you could then have to modify things that you shouldn't.  We've
thought a lot about what would be useful, perhaps just returning the
stringified version of it's class info.  Dunno, ideas?

Chris
-- 
| Christopher Petrilli        Python Powered        Digital Creations, Inc.
| petrilli@digicool.com                             http://www.digicool.com