[Zope3-dev] Re: pydoc troubles

Baiju M baiju.m.mail at gmail.com
Sat Sep 9 09:20:41 EDT 2006


On 9/9/06, Baiju M <baiju.m.mail at gmail.com> wrote:
> On 9/8/06, Michael Haubenwallner <michael at d2m.at> 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__'

Well, I ended up with this:
http://sourceforge.net/tracker/index.php?func=detail&aid=718532&group_id=5470&atid=105470

So there is no bug in Zope 3 ?

Regards,
Baiju M


More information about the Zope3-dev mailing list