Re: Conditionally render viewlet

Sylvain Viollon <[email protected]> Thu, 9 Jun 2011 13:31:32 +0200
Newsgroups gmane.comp.web.zope.silva.devel
Organization Infrae
Message-ID <[email protected]>
On Wed, 8 Jun 2011 07:25:48 -0500
Andrew Altepeter <[email protected]> wrote:

> Hi Jon,
> 

  Hello,

> In your viewlet class, define another method:
> 
>     def default_namespace(self):
>         """add 'skip' to the template's namespace.  This method is
> called _after_ update()"""
>         namespace = super(MyViewletClass, self).default_namespace()
>         namespace['skip'] = self.skip
>         return namespace
> 
>

  You should be able to replace this with:

  def namespace(self):
      return {'skip': self.skip}

  And have the same result.

  However surcharging filter on the ViewletManager is the nicest way to
  ignore a Viewlet, I think.

  Regards,

  Sylvain

-- 
Sylvain Viollon -- Infrae
t +31 10 243 7051 -- http://infrae.com
Hoevestraat 10 3033GC Rotterdam -- The Netherlands