Re: Conditionally render viewlet
Andrew Altepeter <[email protected]> Wed, 8 Jun 2011 07:25:48 -0500
| Newsgroups | gmane.comp.web.zope.silva.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============4390400384123977920==
Content-Type: multipart/alternative; boundary=000e0cd56864c0036404a5326f72
--000e0cd56864c0036404a5326f72
Content-Type: text/plain; charset=ISO-8859-1
Hi Jon,
I've gotten around this in my viewlets in this manner:
In the viewlet's update(), I define set a local attribute on the viewlet:
def update(self):
self.skip = False
if self.should_be_skipped():
self.skip = True
And then in the viewlet's template, I do:
<tal:skip condition="not:viewlet/skip">
all viewlet html is inside this
</tal:skip>
While not the most efficient, it does get the job done.
Note than with a view/viewlet's template, you can add variables to the
namespace, so in the above example instead of "not:viewlet/skip" you can
just do "not:skip"...
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
Cheers,
Andy
On Wed, Jun 8, 2011 at 6:37 AM, Jonathan Bowlas <j.bowlas-hclig2XLE9Zaa/[email protected]> wrote:
> Is there an example infrae extension or theme where the filter method
> is overridden?
>
> J
>
> On 8 June 2011 12:35, Jonathan Bowlas <j.bowlas-hclig2XLE9Zaa/[email protected]> wrote:
> > Sorry but it's still not working, I did this:
> >
> > class LeftColumn(silvaviews.ViewletManager):
> > """Left Content Area
> > """
> > def filter(self):
> > viewlets = super(LeftColumn, self).filter()
> > return [v for v in viewlets if v.available()]
> >
> > But it returns this traceback:
> >
> > 2011-06-08 12:30:35,868 ERROR [infrae.wsgi]
> > Error while rendering error message
> > Object class: Products.Silva.Root.Root
> > Object path: /silva
> > Request URL: http://localhost:8080/silva/test/@@index.html
> > Request method: GET
> > User: admin
> > User-agent: Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101
> Firefox/4.0.1
> > Refer: http://localhost:8080/silva/test
> > Traceback (innermost last):
> > Module infrae.wsgi.publisher, line 183, in error
> > Module silva.core.views.views, line 73, in __call__
> > Module infrae.layout.components, line 105, in __call__
> > - Published class: silva.core.layout.porto.errors.OtherErrorPage
> > - Object path: /silva
> > - Object type: Silva Root
> > Module infrae.layout.components, line 77, in __call__
> > Module infrae.layout.components, line 70, in render
> > Module infrae.layout.components, line 67, in _render_template
> > Module five.grok.components, line 133, in render
> > Module zope.pagetemplate.pagetemplate, line 113, in pt_render
> > Module zope.tal.talinterpreter, line 271, in __call__
> > Module zope.tal.talinterpreter, line 343, in interpret
> > Module zope.tal.talinterpreter, line 531, in do_optTag_tal
> > Module zope.tal.talinterpreter, line 513, in no_tag
> > Module zope.tal.talinterpreter, line 343, in interpret
> > Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal
> > Module Products.PageTemplates.Expressions, line 220, in
> evaluateStructure
> > Module zope.tales.tales, line 696, in evaluate
> > - URL:
> c:\silva-2.3.1\eggs\silva.core.layout-2.3.2-py2.6.egg\silva\core\layout\porto\porto_templates\
> mainlayout.pt
> > - Line 29, Column 4
> > - Expression: <StringExpr u'layout'>
> > - Names:
> > {'args': (),
> > 'container': <Root at /silva>,
> > 'context': <Root at /silva>,
> > 'default': <object object at 0x01AD1720>,
> > 'here': <Root at /silva>,
> > 'layout':
> > <silvatheme.uclcorporateidentity.uclcorporateidentity.MainErrorLayout
> > object at 0x0722CE10>,
> > 'loop': {},
> > 'nothing': None,
> > 'options': {},
> > 'repeat': <Products.PageTemplates.Expressions.SafeMapping
> > object at 0x0721D660>,
> > 'request': <WSGIRequest,
> > URL=http://localhost:8080/silva/test/@@index.html>,
> > 'root': <Application at >,
> > 'static': <silva.resourceinclude.resource.ResourceView object
> > at 0x0722C750>,
> > 'template':
> > <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at
> > 0x06364A90>,
> > 'traverse_subpath': [],
> > 'user': <User 'admin'>,
> > 'view': <silva.core.layout.porto.errors.OtherErrorPage object
> > at 0x06A63BF0>,
> > 'views': <Products.Five.browser.pagetemplatefile.ViewMapper
> > object at 0x0723A6D0>}
> > Module zope.contentprovider.tales, line 80, in __call__
> > Module grokcore.viewlet.components, line 80, in render
> > Module five.grok.components, line 133, in render
> > Module zope.pagetemplate.pagetemplate, line 113, in pt_render
> > Module zope.tal.talinterpreter, line 271, in __call__
> > Module zope.tal.talinterpreter, line 343, in interpret
> > Module zope.tal.talinterpreter, line 533, in do_optTag_tal
> > Module zope.tal.talinterpreter, line 518, in do_optTag
> > Module zope.tal.talinterpreter, line 513, in no_tag
> > Module zope.tal.talinterpreter, line 343, in interpret
> > Module zope.tal.talinterpreter, line 852, in do_condition
> > Module zope.tal.talinterpreter, line 343, in interpret
> > Module zope.tal.talinterpreter, line 531, in do_optTag_tal
> > Module zope.tal.talinterpreter, line 513, in no_tag
> > Module zope.tal.talinterpreter, line 343, in interpret
> > Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal
> > Module Products.PageTemplates.Expressions, line 220, in
> evaluateStructure
> > Module zope.tales.tales, line 696, in evaluate
> > - URL:
> c:\silva-2.3.1\src\silvatheme.uclcorporateidentity\silvatheme\uclcorporateidentity\uclcorporateidentity_templates\
> layout.pt
> > - Line 5, Column 8
> > - Expression: <StringExpr u'threecolumn'>
> > - Names:
> > {'args': (),
> > 'container': <Root at /silva>,
> > 'context': <Root at /silva>,
> > 'default': <object object at 0x01AD1720>,
> > 'here': <Root at /silva>,
> > 'layout':
> > <silvatheme.uclcorporateidentity.uclcorporateidentity.MainErrorLayout
> > object at 0x0722CE10>,
> > 'loop': {},
> > 'nothing': None,
> > 'options': {},
> > 'provider':
> > <silvatheme.uclcorporateidentity.uclcorporateidentity.Layout object at
> > 0x072033F0>,
> > 'repeat': <Products.PageTemplates.Expressions.SafeMapping
> > object at 0x0721D690>,
> > 'request': <WSGIRequest,
> > URL=http://localhost:8080/silva/test/@@index.html>,
> > 'root': <Application at >,
> > 'static': <silva.resourceinclude.resource.ResourceView object
> > at 0x07234D30>,
> > 'template':
> > <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at
> > 0x063EF510>,
> > 'traverse_subpath': [],
> > 'user': <User 'admin'>,
> > 'view': <silva.core.layout.porto.errors.OtherErrorPage object
> > at 0x06A63BF0>,
> > 'viewletmanager':
> > <silvatheme.uclcorporateidentity.uclcorporateidentity.Layout object at
> > 0x072033F0>,
> > 'views': <Products.Five.browser.pagetemplatefile.ViewMapper
> > object at 0x07234DB0>}
> > Module zope.contentprovider.tales, line 80, in __call__
> > Module grokcore.viewlet.components, line 80, in render
> > Module five.grok.components, line 133, in render
> > Module zope.pagetemplate.pagetemplate, line 113, in pt_render
> > Module zope.tal.talinterpreter, line 271, in __call__
> > Module zope.tal.talinterpreter, line 343, in interpret
> > Module zope.tal.talinterpreter, line 531, in do_optTag_tal
> > Module zope.tal.talinterpreter, line 513, in no_tag
> > Module zope.tal.talinterpreter, line 343, in interpret
> > Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal
> > Module Products.PageTemplates.Expressions, line 220, in
> evaluateStructure
> > Module zope.tales.tales, line 696, in evaluate
> > - URL:
> c:\silva-2.3.1\src\silvatheme.uclcorporateidentity\silvatheme\uclcorporateidentity\uclcorporateidentity_templates\
> threecolumn.pt
> > - Line 6, Column 12
> > - Expression: <StringExpr u'leftcolumn'>
> > - Names:
> > {'args': (),
> > 'container': <Root at /silva>,
> > 'context': <Root at /silva>,
> > 'default': <object object at 0x01AD1720>,
> > 'here': <Root at /silva>,
> > 'layout':
> > <silvatheme.uclcorporateidentity.uclcorporateidentity.MainErrorLayout
> > object at 0x0722CE10>,
> > 'loop': {},
> > 'nothing': None,
> > 'options': {},
> > 'provider':
> > <silvatheme.uclcorporateidentity.uclcorporateidentity.ThreeColumn
> > object at 0x07234ED0>,
> > 'repeat': <Products.PageTemplates.Expressions.SafeMapping
> > object at 0x0721D6F0>,
> > 'request': <WSGIRequest,
> > URL=http://localhost:8080/silva/test/@@index.html>,
> > 'root': <Application at >,
> > 'static': <silva.resourceinclude.resource.ResourceView object
> > at 0x07234F30>,
> > 'template':
> > <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object at
> > 0x063EF7D0>,
> > 'traverse_subpath': [],
> > 'user': <User 'admin'>,
> > 'view': <silva.core.layout.porto.errors.OtherErrorPage object
> > at 0x06A63BF0>,
> > 'viewletmanager':
> > <silvatheme.uclcorporateidentity.uclcorporateidentity.ThreeColumn
> > object at 0x07234ED0>,
> > 'views': <Products.Five.browser.pagetemplatefile.ViewMapper
> > object at 0x07234F50>}
> > Module zope.contentprovider.tales, line 77, in __call__
> > Module zope.viewlet.manager, line 104, in update
> > TypeError: filter() takes exactly 1 argument (2 given)
> >
> > Any Ideas?
> >
> >
> > On 8 June 2011 11:43, Antonin AMAND <[email protected]> wrote:
> >>>> The viewlet still rendered even though theres no index_left.
> >>>> Then I checked the documentation here
> >>>> http://pypi.python.org/pypi/zope.viewlet, specifically the
> >>>> 'ConditionalViewletManager' section where it states that Viewlets have
> >>>> an 'available' attribute (not a method), so I tried setting available
> >>>> = False, but still the viewlet rendered.
> >>
> >> You're right, Viewlet have no available method, I've been mistaken.
> >> What we usually do is this:
> >>
> >> In the viewlet manager we override the filters method :
> >>
> >> class MyViewletManager(...):
> >> ...
> >> def filter(self):
> >> viewlets = super(MyViewletManager, self).filter()
> >> return [v for v in viewlets if v.available()]
> >>
> >> Then define an available method on all viewlets of this ViewletManager.
> >>
> >> BTW, be carefull with hasattr(self.context, 'index_left'), it checks
> >> with acquisition.
> >>
> >> Antonin
> >> _______________________________________________
> >> silva-dev mailing list
> >> silva-dev-IAPFreCvJWM6s/[email protected]
> >> https://lists.infrae.com/mailman/listinfo/silva-dev
> >>
> >
> >
> >
> > --
> > Jonathan Bowlas
> > Web Support Officer
> > Media Services
> > University College London
> > Email: j.bowlas-hclig2XLE9Zaa/[email protected]
> >
>
>
>
> --
> Jonathan Bowlas
> Web Support Officer
> Media Services
> University College London
> Email: j.bowlas-hclig2XLE9Zaa/[email protected]
> _______________________________________________
> silva-dev mailing list
> silva-dev-IAPFreCvJWM6s/[email protected]
> https://lists.infrae.com/mailman/listinfo/silva-dev
>
--000e0cd56864c0036404a5326f72
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Hi Jon,<div><br></div><div>I've gotten around this in my viewlets in th=
is manner:</div><div><br></div><div>In the viewlet's update(), I define=
set a local attribute on the viewlet:</div><div><br></div><div><div>=A0=A0=
=A0def update(self):</div>
<div>=A0=A0 =A0 =A0 =A0self.skip =3D False</div><div>=A0=A0 =A0 =A0 =A0if s=
elf.should_be_skipped():</div><div>=A0=A0 =A0 =A0 =A0 =A0 =A0self.skip =3D =
True</div><div><br></div><div>And then in the viewlet's template, I do:=
</div><div><br></div><div><tal:skip condition=3D"not:viewlet/skip&q=
uot;></div>
<div>=A0=A0all viewlet html is inside this</div><div></tal:skip></div=
><div><br></div><div>While not the most efficient, it does get the job done=
.</div><div><br></div><div>Note than with a view/viewlet's template, yo=
u can add variables to the namespace, so in the above example instead of &q=
uot;not:viewlet/skip" you can just do "not:skip"...</div>
<div><br></div><div>In your viewlet class, define another method:</div><div=
><br></div><div><div>=A0=A0 =A0def default_namespace(self):</div><div>=A0=
=A0 =A0 =A0 =A0"""add 'skip' to the template's n=
amespace. =A0This method is called _after_ update()"""</div>
<div>=A0=A0 =A0 =A0 =A0namespace =3D super(MyViewletClass, self).default_na=
mespace()</div><div>=A0=A0 =A0 =A0 =A0namespace['skip'] =3D self.sk=
ip</div><div>=A0=A0 =A0 =A0 =A0return namespace</div></div><div><br></div><=
div>Cheers,</div><div>Andy</div>
<br><div class=3D"gmail_quote">On Wed, Jun 8, 2011 at 6:37 AM, Jonathan Bow=
las <span dir=3D"ltr"><<a href=3D"mailto:j.bowlas-hclig2XLE9Zaa/[email protected]">j.bowlas@uc=
l.ac.uk</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Is there an example infrae extension or theme where the filter method<br>
is overridden?<br>
<font color=3D"#888888"><br>
J<br>
</font><div><div></div><div class=3D"h5"><br>
On 8 June 2011 12:35, Jonathan Bowlas <<a href=3D"mailto:[email protected]=
.uk">j.bowlas-hclig2XLE9Zaa/[email protected]</a>> wrote:<br>
> Sorry but it's still not working, I did this:<br>
><br>
> class LeftColumn(silvaviews.ViewletManager):<br>
> =A0 =A0"""Left Content Area<br>
> =A0 =A0"""<br>
> =A0 =A0def filter(self):<br>
> =A0 =A0 =A0 =A0 viewlets =3D super(LeftColumn, self).filter()<br>
> =A0 =A0 =A0 =A0 return [v for v in viewlets if v.available()]<br>
><br>
> But it returns this traceback:<br>
><br>
> 2011-06-08 12:30:35,868 ERROR [infrae.wsgi]<br>
> Error while rendering error message<br>
> Object class: Products.Silva.Root.Root<br>
> Object path: /silva<br>
> Request URL: <a href=3D"http://localhost:8080/silva/test/@@index.html"=
target=3D"_blank">http://localhost:8080/silva/test/@@index.html</a><br>
> Request method: GET<br>
> User: admin<br>
> User-agent: Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Fire=
fox/4.0.1<br>
> Refer: <a href=3D"http://localhost:8080/silva/test" target=3D"_blank">=
http://localhost:8080/silva/test</a><br>
> Traceback (innermost last):<br>
> =A0Module infrae.wsgi.publisher, line 183, in error<br>
> =A0Module silva.core.views.views, line 73, in __call__<br>
> =A0Module infrae.layout.components, line 105, in __call__<br>
> =A0 - Published class: silva.core.layout.porto.errors.OtherErrorPage<b=
r>
> =A0 - Object path: /silva<br>
> =A0 - Object type: Silva Root<br>
> =A0Module infrae.layout.components, line 77, in __call__<br>
> =A0Module infrae.layout.components, line 70, in render<br>
> =A0Module infrae.layout.components, line 67, in _render_template<br>
> =A0Module five.grok.components, line 133, in render<br>
> =A0Module zope.pagetemplate.pagetemplate, line 113, in pt_render<br>
> =A0Module zope.tal.talinterpreter, line 271, in __call__<br>
> =A0Module zope.tal.talinterpreter, line 343, in interpret<br>
> =A0Module zope.tal.talinterpreter, line 531, in do_optTag_tal<br>
> =A0Module zope.tal.talinterpreter, line 513, in no_tag<br>
> =A0Module zope.tal.talinterpreter, line 343, in interpret<br>
> =A0Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal=
<br>
> =A0Module Products.PageTemplates.Expressions, line 220, in evaluateStr=
ucture<br>
> =A0Module zope.tales.tales, line 696, in evaluate<br>
> =A0 - URL: c:\silva-2.3.1\eggs\silva.core.layout-2.3.2-py2.6.egg\silva=
\core\layout\porto\porto_templates\<a href=3D"http://mainlayout.pt" target=
=3D"_blank">mainlayout.pt</a><br>
> =A0 - Line 29, Column 4<br>
> =A0 - Expression: <StringExpr u'layout'><br>
> =A0 - Names:<br>
> =A0 =A0 =A0{'args': (),<br>
> =A0 =A0 =A0 'container': <Root at /silva>,<br>
> =A0 =A0 =A0 'context': <Root at /silva>,<br>
> =A0 =A0 =A0 'default': <object object at 0x01AD1720>,<br=
>
> =A0 =A0 =A0 'here': <Root at /silva>,<br>
> =A0 =A0 =A0 'layout':<br>
> <silvatheme.uclcorporateidentity.uclcorporateidentity.MainErrorLayo=
ut<br>
> object at 0x0722CE10>,<br>
> =A0 =A0 =A0 'loop': {},<br>
> =A0 =A0 =A0 'nothing': None,<br>
> =A0 =A0 =A0 'options': {},<br>
> =A0 =A0 =A0 'repeat': <Products.PageTemplates.Expressions.S=
afeMapping<br>
> object at 0x0721D660>,<br>
> =A0 =A0 =A0 'request': <WSGIRequest,<br>
> URL=3D<a href=3D"http://localhost:8080/silva/test/@@index.html" target=
=3D"_blank">http://localhost:8080/silva/test/@@index.html</a>>,<br>
> =A0 =A0 =A0 'root': <Application at >,<br>
> =A0 =A0 =A0 'static': <silva.resourceinclude.resource.Resou=
rceView object<br>
> at 0x0722C750>,<br>
> =A0 =A0 =A0 'template':<br>
> <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object=
at<br>
> 0x06364A90>,<br>
> =A0 =A0 =A0 'traverse_subpath': [],<br>
> =A0 =A0 =A0 'user': <User 'admin'>,<br>
> =A0 =A0 =A0 'view': <silva.core.layout.porto.errors.OtherEr=
rorPage object<br>
> at 0x06A63BF0>,<br>
> =A0 =A0 =A0 'views': <Products.Five.browser.pagetemplatefil=
e.ViewMapper<br>
> object at 0x0723A6D0>}<br>
> =A0Module zope.contentprovider.tales, line 80, in __call__<br>
> =A0Module grokcore.viewlet.components, line 80, in render<br>
> =A0Module five.grok.components, line 133, in render<br>
> =A0Module zope.pagetemplate.pagetemplate, line 113, in pt_render<br>
> =A0Module zope.tal.talinterpreter, line 271, in __call__<br>
> =A0Module zope.tal.talinterpreter, line 343, in interpret<br>
> =A0Module zope.tal.talinterpreter, line 533, in do_optTag_tal<br>
> =A0Module zope.tal.talinterpreter, line 518, in do_optTag<br>
> =A0Module zope.tal.talinterpreter, line 513, in no_tag<br>
> =A0Module zope.tal.talinterpreter, line 343, in interpret<br>
> =A0Module zope.tal.talinterpreter, line 852, in do_condition<br>
> =A0Module zope.tal.talinterpreter, line 343, in interpret<br>
> =A0Module zope.tal.talinterpreter, line 531, in do_optTag_tal<br>
> =A0Module zope.tal.talinterpreter, line 513, in no_tag<br>
> =A0Module zope.tal.talinterpreter, line 343, in interpret<br>
> =A0Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal=
<br>
> =A0Module Products.PageTemplates.Expressions, line 220, in evaluateStr=
ucture<br>
> =A0Module zope.tales.tales, line 696, in evaluate<br>
> =A0 - URL: c:\silva-2.3.1\src\silvatheme.uclcorporateidentity\silvathe=
me\uclcorporateidentity\uclcorporateidentity_templates\<a href=3D"http://la=
yout.pt" target=3D"_blank">layout.pt</a><br>
> =A0 - Line 5, Column 8<br>
> =A0 - Expression: <StringExpr u'threecolumn'><br>
> =A0 - Names:<br>
> =A0 =A0 =A0{'args': (),<br>
> =A0 =A0 =A0 'container': <Root at /silva>,<br>
> =A0 =A0 =A0 'context': <Root at /silva>,<br>
> =A0 =A0 =A0 'default': <object object at 0x01AD1720>,<br=
>
> =A0 =A0 =A0 'here': <Root at /silva>,<br>
> =A0 =A0 =A0 'layout':<br>
> <silvatheme.uclcorporateidentity.uclcorporateidentity.MainErrorLayo=
ut<br>
> object at 0x0722CE10>,<br>
> =A0 =A0 =A0 'loop': {},<br>
> =A0 =A0 =A0 'nothing': None,<br>
> =A0 =A0 =A0 'options': {},<br>
> =A0 =A0 =A0 'provider':<br>
> <silvatheme.uclcorporateidentity.uclcorporateidentity.Layout object=
at<br>
> 0x072033F0>,<br>
> =A0 =A0 =A0 'repeat': <Products.PageTemplates.Expressions.S=
afeMapping<br>
> object at 0x0721D690>,<br>
> =A0 =A0 =A0 'request': <WSGIRequest,<br>
> URL=3D<a href=3D"http://localhost:8080/silva/test/@@index.html" target=
=3D"_blank">http://localhost:8080/silva/test/@@index.html</a>>,<br>
> =A0 =A0 =A0 'root': <Application at >,<br>
> =A0 =A0 =A0 'static': <silva.resourceinclude.resource.Resou=
rceView object<br>
> at 0x07234D30>,<br>
> =A0 =A0 =A0 'template':<br>
> <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object=
at<br>
> 0x063EF510>,<br>
> =A0 =A0 =A0 'traverse_subpath': [],<br>
> =A0 =A0 =A0 'user': <User 'admin'>,<br>
> =A0 =A0 =A0 'view': <silva.core.layout.porto.errors.OtherEr=
rorPage object<br>
> at 0x06A63BF0>,<br>
> =A0 =A0 =A0 'viewletmanager':<br>
> <silvatheme.uclcorporateidentity.uclcorporateidentity.Layout object=
at<br>
> 0x072033F0>,<br>
> =A0 =A0 =A0 'views': <Products.Five.browser.pagetemplatefil=
e.ViewMapper<br>
> object at 0x07234DB0>}<br>
> =A0Module zope.contentprovider.tales, line 80, in __call__<br>
> =A0Module grokcore.viewlet.components, line 80, in render<br>
> =A0Module five.grok.components, line 133, in render<br>
> =A0Module zope.pagetemplate.pagetemplate, line 113, in pt_render<br>
> =A0Module zope.tal.talinterpreter, line 271, in __call__<br>
> =A0Module zope.tal.talinterpreter, line 343, in interpret<br>
> =A0Module zope.tal.talinterpreter, line 531, in do_optTag_tal<br>
> =A0Module zope.tal.talinterpreter, line 513, in no_tag<br>
> =A0Module zope.tal.talinterpreter, line 343, in interpret<br>
> =A0Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal=
<br>
> =A0Module Products.PageTemplates.Expressions, line 220, in evaluateStr=
ucture<br>
> =A0Module zope.tales.tales, line 696, in evaluate<br>
> =A0 - URL: c:\silva-2.3.1\src\silvatheme.uclcorporateidentity\silvathe=
me\uclcorporateidentity\uclcorporateidentity_templates\<a href=3D"http://th=
reecolumn.pt" target=3D"_blank">threecolumn.pt</a><br>
> =A0 - Line 6, Column 12<br>
> =A0 - Expression: <StringExpr u'leftcolumn'><br>
> =A0 - Names:<br>
> =A0 =A0 =A0{'args': (),<br>
> =A0 =A0 =A0 'container': <Root at /silva>,<br>
> =A0 =A0 =A0 'context': <Root at /silva>,<br>
> =A0 =A0 =A0 'default': <object object at 0x01AD1720>,<br=
>
> =A0 =A0 =A0 'here': <Root at /silva>,<br>
> =A0 =A0 =A0 'layout':<br>
> <silvatheme.uclcorporateidentity.uclcorporateidentity.MainErrorLayo=
ut<br>
> object at 0x0722CE10>,<br>
> =A0 =A0 =A0 'loop': {},<br>
> =A0 =A0 =A0 'nothing': None,<br>
> =A0 =A0 =A0 'options': {},<br>
> =A0 =A0 =A0 'provider':<br>
> <silvatheme.uclcorporateidentity.uclcorporateidentity.ThreeColumn<b=
r>
> object at 0x07234ED0>,<br>
> =A0 =A0 =A0 'repeat': <Products.PageTemplates.Expressions.S=
afeMapping<br>
> object at 0x0721D6F0>,<br>
> =A0 =A0 =A0 'request': <WSGIRequest,<br>
> URL=3D<a href=3D"http://localhost:8080/silva/test/@@index.html" target=
=3D"_blank">http://localhost:8080/silva/test/@@index.html</a>>,<br>
> =A0 =A0 =A0 'root': <Application at >,<br>
> =A0 =A0 =A0 'static': <silva.resourceinclude.resource.Resou=
rceView object<br>
> at 0x07234F30>,<br>
> =A0 =A0 =A0 'template':<br>
> <Products.Five.browser.pagetemplatefile.ViewPageTemplateFile object=
at<br>
> 0x063EF7D0>,<br>
> =A0 =A0 =A0 'traverse_subpath': [],<br>
> =A0 =A0 =A0 'user': <User 'admin'>,<br>
> =A0 =A0 =A0 'view': <silva.core.layout.porto.errors.OtherEr=
rorPage object<br>
> at 0x06A63BF0>,<br>
> =A0 =A0 =A0 'viewletmanager':<br>
> <silvatheme.uclcorporateidentity.uclcorporateidentity.ThreeColumn<b=
r>
> object at 0x07234ED0>,<br>
> =A0 =A0 =A0 'views': <Products.Five.browser.pagetemplatefil=
e.ViewMapper<br>
> object at 0x07234F50>}<br>
> =A0Module zope.contentprovider.tales, line 77, in __call__<br>
> =A0Module zope.viewlet.manager, line 104, in update<br>
> TypeError: filter() takes exactly 1 argument (2 given)<br>
><br>
> Any Ideas?<br>
><br>
><br>
> On 8 June 2011 11:43, Antonin AMAND <<a href=3D"mailto:antonin@infr=
ae.com">[email protected]</a>> wrote:<br>
>>>> The viewlet still rendered even though theres no index_lef=
t.<br>
>>>> Then I checked the documentation here<br>
>>>> <a href=3D"http://pypi.python.org/pypi/zope.viewlet" targe=
t=3D"_blank">http://pypi.python.org/pypi/zope.viewlet</a>, specifically the=
<br>
>>>> 'ConditionalViewletManager' section where it state=
s that Viewlets have<br>
>>>> an 'available' attribute (not a method), so I trie=
d setting available<br>
>>>> =3D False, =A0but still the viewlet rendered.<br>
>><br>
>> You're right, Viewlet have no available method, I've been =
mistaken.<br>
>> What we usually do is this:<br>
>><br>
>> In the viewlet manager we override the filters method :<br>
>><br>
>> class MyViewletManager(...):<br>
>> =A0 ...<br>
>> =A0 def filter(self):<br>
>> =A0 =A0 =A0viewlets =3D super(MyViewletManager, self).filter()<br>
>> =A0 =A0 =A0return [v for v in viewlets if v.available()]<br>
>><br>
>> Then define an available method on all viewlets of this ViewletMan=
ager.<br>
>><br>
>> BTW, be carefull with hasattr(self.context, 'index_left'),=
it checks<br>
>> with acquisition.<br>
>><br>
>> Antonin<br>
>> _______________________________________________<br>
>> silva-dev mailing list<br>
>> <a href=3D"mailto:silva-dev-IAPFreCvJWM6s/[email protected]">[email protected]=
ae.com</a><br>
>> <a href=3D"https://lists.infrae.com/mailman/listinfo/silva-dev" ta=
rget=3D"_blank">https://lists.infrae.com/mailman/listinfo/silva-dev</a><br>
>><br>
><br>
><br>
><br>
> --<br>
> Jonathan Bowlas<br>
> Web Support Officer<br>
> Media Services<br>
> University College London<br>
> Email: <a href=3D"mailto:j.bowlas-hclig2XLE9Zaa/[email protected]">j.bowlas-hclig2XLE9Zaa/[email protected]</a><br=
>
><br>
<br>
<br>
<br>
--<br>
Jonathan Bowlas<br>
Web Support Officer<br>
Media Services<br>
University College London<br>
Email: <a href=3D"mailto:j.bowlas-hclig2XLE9Zaa/[email protected]">j.bowlas-hclig2XLE9Zaa/[email protected]</a><br>
_______________________________________________<br>
silva-dev mailing list<br>
<a href=3D"mailto:silva-dev-IAPFreCvJWM6s/[email protected]">silva-dev-IAPFreCvJWM6s/[email protected]</a=
><br>
<a href=3D"https://lists.infrae.com/mailman/listinfo/silva-dev" target=3D"_=
blank">https://lists.infrae.com/mailman/listinfo/silva-dev</a><br>
</div></div></blockquote></div><br></div>
--000e0cd56864c0036404a5326f72--
--===============4390400384123977920==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
silva-dev mailing list
silva-dev-IAPFreCvJWM6s/[email protected]
https://lists.infrae.com/mailman/listinfo/silva-dev
--===============4390400384123977920==--