[Grok-dev] Viewlets: Check for availability

Danilo G B danilogbotelho at yahoo.com
Tue Jun 14 15:14:46 EDT 2011


Hi, guys.

I was wondering why viewlets in Grok, like viewlets in Plone, don't have a 
method to check their availability at the render time.
This would be as simple as changing the last line in the render method of the 
ViewletManager component (grokcore.viewlet:components.py):

class ViewletManager(ViewletManagerBase):
    ...
    def render(self):
        ....
   -- return u'\n'.join([viewlet.render() for viewlet in self.viewlets])
  ++ return u'\n'.join([viewlet.render() for viewlet in self.viewlets if 
viewlet.available()])

and adding the available method to Viewlet:

class Viewlet(ViewletBase):
    ...

    def available(self):
        return True
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20110614/bb1d2059/attachment.html 


More information about the Grok-dev mailing list