Hi,
Try testing the context interface in update.
dorender = False
def update(self):
if MyInterface.providedBy(self.context):
self.dorender = True
def render(self):
if self.dorender:
return u'Hello'
else:
return u''
That may do it.
Regards,
Darryl
On Wed, 2006-09-13 at 20:59 +0200, Luis De la Parra wrote:
> hello,
>
> I'm trying to get started with viewlets, but am still having some problems:
>
> For example, I have a "LeftColumn" viewletmanager, where I want to display
> different infos (viewlets) depending on the object that's being displayed
> (one viewlet for folders, one for "normal" files, one for images, etc)
>
> the following example works either for all interfaces or for none, and I'm
> trying to figure out how to render a particular viewlet only for a
> particular interface...
>
> any pointers in the right direction? thanx a lot! Luis
>
>
> test/__init__.py
>
> from zope import component
> from zope import interface
> from zope import viewlet
>
> class ILeftColumn(viewlet.interfaces.IViewletManager):
> """ Viewlet manager for the left column"""
>
>
> class HelloMessage(object):
> interface.implements(viewlet.interfaces.IViewlet)
>
> def __init__(self,context,request,view,manager):
> self.__parent__ = view
> self.context, self.request = context,request
>
> def update(self):
> pass
>
> def render(self):
> return u'Hello!'
>
> test/configure.zcml
>
> xmlns="http://namespaces.zope.org/zope";
> xmlns:browser="http://namespaces.zope.org/browser";>
>
> for="*"
>name="viewlet.html"
>template="index.pt"
>permission="zope.View"/>
>
>name="vm"
> permission="zope.Public"
> provides=".ILeftColumn"
> template="vm.pt"/>
>
>
>name="hello"
> for="zope.app.file.interfaces.IFile"
> manager=".ILeftColumn"
> class=".HelloMessage"
> permission="zope.Public"/>
>
>
>
>
>
>
> ___
> Zope3-users mailing list
> Zope3-users@zope.org
> http://mail.zope.org/mailman/listinfo/zope3-users
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users