[Zope-dev] testing types in PythonScripts
Florent Guillaume
fg@nuxeo.com
28 Sep 2001 12:10:39 GMT
Python Script has a same_type(x,y) function.
Florent Guillaume
Nuxeo
Steve Alexander <steve@cat-box.net> wrote:
> I have a variable, f.
>
> The value of f might be a list, or it might be a string.
>
> I want to do different things to f depending what type it is.
>
> How do I check its type from a PythonScript?
>
>
> I can't use type(), as this opens up a security hole with Extension
> Classes, where the type is the class.
>
> I can't import types, as that seems to be restricted.
>
>
> I suggest that either one or both of the following be altered:
>
> * The types module is allowed to be imported into restricted stuff.
>
> * A safe version of type() is put into the restricted global namespace.
>
>
> I seem to recall a discussion of this a few months ago, where someone
> (Evan?) proposed a safe version of type(). I guess this got lost in the
> conversion to RestrictedPython with Zope 2.4.
>
>
> Oh yeah... an ugly workaround is to try to append to f and see if you
> get and AttributeError.
>
> --
> Steve Alexander
> Software Engineer
> Cat-Box limited
>
>
> _______________________________________________
> Zope-Dev maillist - Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope )
>
--
Florent Guillaume, Nuxeo SARL (Paris, France)
+33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com