[Grok-dev] How to effectively reuse viewlets?

prinzdezibel prinzdezibel at googlemail.com
Sun Oct 18 03:43:52 EDT 2009

Martin Aspeli-3 wrote:
> 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
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev

I Martin,
thanks for your reply. Could you please write down a sample snippet of code
for your suggested solution. Because I tried to override the render method
of the viewlet in my derived viewlet and got a ambiguous render method
error, because my original viewlet is rendered from a template.
View this message in context: http://www.nabble.com/How-to-effectively-reuse-viewlets--tp25941437p25944605.html
Sent from the Grok mailing list archive at Nabble.com.

More information about the Grok-dev mailing list