Re: [Zope3-Users] viewlets for specific interfaces

2006-09-14 Thread Stephan Richter
On Wednesday 13 September 2006 14:59, Luis De la Parra wrote:
> 

This should work for IFile. I am positive this works correctly; we use it all 
the time.

The problem is that I cannot help you much here, because we do not have  a 
traceback and I do not have the package. If you make the package available, I 
will try to have a look at it.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] viewlets for specific interfaces

2006-09-13 Thread Darryl Cousins
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


[Zope3-Users] viewlets for specific interfaces

2006-09-13 Thread Luis De la Parra

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

http://namespaces.zope.org/zope";
xmlns:browser="http://namespaces.zope.org/browser";>

  

  


  






___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users