[Zope3-Users] Re: How can I get a viewlet's docstring from within
aviewlet manager?
Andreas Johnsen
andreas.johnsen at bouvet.no
Thu Jun 19 03:12:09 EDT 2008
Thanks, that solved my problem. Now I can get hold of the docstring I
want with "viewlet.__class__.__base__.__doc__"
Andreas
> -----Original Message-----
> From: zope3-users-bounces at zope.org
> [mailto:zope3-users-bounces at zope.org] On Behalf Of Philipp
> von Weitershausen
> Sent: 14. juni 2008 11:22
> To: zope3-users at zope.org
> Subject: [Zope3-Users] Re: How can I get a viewlet's
> docstring from within aviewlet manager?
>
> Andreas Johnsen wrote:
> > Let's say I have defined 'class MyViewlet(viewlet.ViewletBase)' and
> > registered it with the <browser:viewlet> directive. The class
> > 'MyViewlet' has a docstring. How can I get this docstring from the
> > render() method in a viewlet manager?
> >
> > In the viewlet manager the viewlet instance is an instance of
> > 'zope.viewlet.metaconfigure.MyViewlet' and not my class 'MyViewlet'.
>
> Yeah. Dynamic class generation sucks. For some reason, the
> bad example led by browser:page et.al. has caught on and now
> nearly all browser-related ZCML directives do it.
>
> > Is there a path from 'zope.viewlet.metaconfigure.MyViewlet' to the
> > class 'MyViewlet' or any other suggestions on how to get
> the docstring
> > defined in my class from a viewlet manager?
>
> You could get the right base class from __bases__ and look at
> that class's __doc__.
>
> _______________________________________________
> Zope3-users mailing list
> Zope3-users at zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
>
More information about the Zope3-users
mailing list