Re: [Zope3-dev] Re: pydoc troubles
On 9/9/06, Baiju M <[EMAIL PROTECTED]> wrote: 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 = > '/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 "", 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 ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] Re: pydoc troubles
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 = '/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 "", 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
[Zope3-dev] Re: pydoc troubles
Stephan Richter wrote: On Friday 08 September 2006 09:03, Philipp von Weitershausen wrote: Of course, that'd take a lot of resources (which we aren't likely to have) and it always sems a good idea to at least *allow* third party software to work with Zope. The API in apidoc is developed in a way that it supports other output formats. I tried to cleanly separate, information extraction, information combination, representation atoms and full representation. I imagine that you could easily build an interface to pydoc using apidoc. If the entire apidoc package is too much overhead, then the pacakge could be split to support those simpler cases. Apidoc provides the same information as pydoc, in a different layout and structured at different levels. Even more, apidoc adds interface and adapter information due to the runtime wiring. Apidoc is limited to the browser and a running zope instance (or a static copy) atm. Pydoc can be used from the shell, to write to a file, from the python interpreter, from inside the zope debugger and through the browser (running its own HTTP server). Apidoc provides more information, while pydoc provides more ways to use it. Michael -- http://zope.org/Members/d2m http://planetzope.org ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
[Zope3-dev] Re: pydoc troubles
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 = '/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. Thanks for looking into this Michael -- http://zope.org/Members/d2m http://planetzope.org ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
[Zope3-dev] Re: pydoc troubles
On Friday 08 September 2006 09:03, Philipp von Weitershausen wrote: > Of course, that'd take a lot of resources (which we aren't likely to > have) and it always sems a good idea to at least *allow* third party > software to work with Zope. The API in apidoc is developed in a way that it supports other output formats. I tried to cleanly separate, information extraction, information combination, representation atoms and full representation. I imagine that you could easily build an interface to pydoc using apidoc. If the entire apidoc package is too much overhead, then the pacakge could be split to support those simpler cases. Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
[Zope3-dev] Re: pydoc troubles
Stephan Richter wrote: On Friday 08 September 2006 03:13, Michael Haubenwallner wrote: i have a small problem using pydoc to look at the Zope3 source, namely zope.proxy and modules where zope.proxy is included: Why would you use pydoc? Any conventional documentation tools are useless in Zope 3, because they do not take interfaces and component registrations into account. Instead, I would be really happy, if people would keep developing APIDOC, which serves much better for Zope 3. I don't think conventional documentation are completely useless. APIDoc won't always be around for zope.* software, especially when that software is distributed separately. I see a need developer docs for them. Of course, we could make APIDoc a lot less zope.app dependent and also support a static output. The online browsing via ++apidoc++ would then just be sugar. Of course, that'd take a lot of resources (which we aren't likely to have) and it always sems a good idea to at least *allow* third party software to work with Zope. Philipp ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
[Zope3-dev] Re: pydoc troubles
Michael Haubenwallner wrote: i have a small problem using pydoc to look at the Zope3 source, namely zope.proxy and modules where zope.proxy is included: running "pydoc2.4 zope.proxy" or "pydoc2.4 zope.proxy._zope_proxy_proxy" from the shell yields problem in zope.component - ImportError: /path/to/Zope3/src/zope/proxy/_zope_proxy_proxy.so: undefined symbol: PyUnicodeUCS2_AsEncodedString Sorry, my fault -- its been different python versions that created the problem (thanks to baijum for pointing this out in IRC), i should have looked closer. 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 = '/path/to/Zope3/src/zope/component/__init__.pyc' - I'd really like to make Zope3 code look good and complete from pydoc. Thanks for your hints again Michael -- http://zope.org/Members/d2m http://planetzope.org ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com