[Grok-dev] How to effectively reuse viewlets?
Martin Aspeli
optilude+lists at gmail.com
Sat Oct 17 23:17:18 EDT 2009
prinzdezibel wrote:
> Hi guys, I stumbled upon a problem when doing my first steps with grok/zope.
> Maybe somebody of you smart people can help me!
> See, I wanted to reuse an existing viewlet that is contained in a package I
> don't own and I don't want to modify. Basically I want to have this very
> viewlet handled by another viewletmanager. Therefore I subclassed the
> viewlet and tried to register it to a different viewletmanager via
> grok.viewletmanager(MyViewletManager)
>
> The problem is now that my viewlet is rendered twice. From the original
> viewletmanager and from mine. How can I prevent the viewlet to be rendered
> from it's original viewletmanager which is placed in the mentioned package I
> don't own. Is it possible to unregister a viewlet from its manager?
You can register a new viewlet with the same name for a more specific
interface (e.g. a browser layer) and renders to nothing.
Plone has other solutions (its viewlet managers allow re-ordering and
turning off of viewlets), but that's the simplest way in plain Zope.
Martin
--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
More information about the Grok-dev
mailing list