On 9/8/06, Michael Haubenwallner <[EMAIL PROTECTED]> wrote:
Michael Haubenwallner wrote:
> Anyway, using the right paths i get back to where i initially started:
> the package information is not displayed for several packages
>
> pydoc displays package information on zope.proxy, zope.component,
> zope.interface for example like this:
>
> -----
> Help on package zope.component in zope:
>
> zope.component = <module 'zope.component' from
> '/path/to/Zope3/src/zope/component/__init__.pyc'
> -----
>
> I'd really like to make Zope3 code look good and complete from pydoc.
>

Actually what makes pydoc display this instead of the package listing is
an AttributeError thrown:
AttributeError: 'Provides' object has no attribute '__name__'

Adding the name attribute to zope.interface.declarations.Provides
makes the Exception go away and renders the pydoc docs correctly.

I wonder if this is the right way to go or if the __name__ attribute was
omitted by design.

If Python's `isclass` function in `inspect` module is correct (I think, it is)
then instance of `zope.interface.declarations.ProvidesClass` should not have
`__bases__` attribute.

This is the `isclass` function from `inspect` module:

 def isclass(object):
     """Return true if the object is a class.

     Class objects provide these attributes:
         __doc__         documentation string
         __module__      name of module in which this class was defined"""
     return isinstance(object, types.ClassType) or hasattr(object, '__bases__')

This `inspect` module is used in `pydoc` to determine types of objects.

So, pydoc treats instance of `zope.interface.declarations.ProvidesClass`
as a class, and try to access `__name__` attribute, then it fails.

Here is a pseudo test case:

 >>> from zope.interface.declarations import ProvidesClass
 >>> ProvidesClass(()).__bases__
 ()
 >>> class C(object): pass
 ...
 >>> C().__bases__
 Traceback (most recent call last):
   File "<stdin>", line 1, in ?
 AttributeError: 'C' object has no attribute '__bases__'

Regards,
Baiju M
_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to