[Zope] how to get info about an object (dir/type)
Nikko Wolf
nikko-wolf at earthlink.net
Thu Jun 30 11:59:05 EDT 2005
See: http://epydoc.sourceforge.net/ (which I have not yet used).
Andreas Jung wrote:
>>> --On 30. Juni 2005 13:48:19 +0200 gabor <gabor at nekomancer.net> wrote:
>>
>> generally.. if i have a reference to an object.
>> how do i find out what his methods are?
>
> By determining its class or meta_type and then by checking the related
> documentation, source code of the class or its base classes? Of course
> type() does not work in RestrictedPython. Bascially you should know the
> objects you're dealing with...otherwise this sounds like a problem with
> your application to me :-) Otherwise use type() from within unrestricted
> code.
While this may be the most direct answer, on my system there are ~2200
Python source files for Zope+Plone. Most of the objects I've tried to
inspect through source code have had multiple parent classes, and some
of the parent classes did, too.
Consequently it can be a long and tedious undertaking to simply find out
which method or attribute name to use, eg: title, Title, getTitle(),
get_title(), Title() ... etc.
Peter Bengtsson wrote:
>>usually i would simply call dir() or type() on the result object,
>>but those are forbidden in zope.
>>
>>how do you usually solve this?
>>
>
> External methods. You might even want to have a general debugging
> script lying around that you can use to exploit dir() and type() and
> __class__.__name__ from your zope.
> Bare in mind that there's a security reason why these aren't available
> in zope but if it's only you using the tools, it's safe.
Peter (or anyone else) -- do you have an Extension that you'd be willing
to share? Or is there one already on Zope.org that I missed?
Nikko
More information about the Zope
mailing list