[Zope3-Users] Views for adapted components
FB
fbo2 at gmx.net
Mon Mar 26 06:57:58 EDT 2007
Hi,
On Mon, Mar 26, 2007 at 12:43:21PM +0200, Lorenzo Gil Sanchez wrote:
[snip]
> This is not so bad. The real problem is that I have to modify the
> original IMyCompoment component to tell zope it implements IImportExport
> even when this is false. The adapter does it, not the compoment. But I
> don't know other way to make my view work with my components.
What you trying to do sounds reasonable at the first moment, but it would be
impossible to accomplish. You try to create an (warning: self invented
expression :-) ) Adaption chain:
object -> some_adapter -> view
which is something, zope doesn't support. Think about it: the publisher would
have to check each possible adapter for a given object trying to create views
for it - and this is just a 2-adaption-chain... .
However, there's an easy solution: Write a view like that:
<page name="im-and-export.html"
for="zope.app.container.interfaces.IContained"
[...]
class=".view.ImExPortView"
menu="zmi_views"
title="Im-&Export"
/>
class ImExPortView(object):
def __call__(self):
try:
export=IImportExport(self.context)
except:
raise NotImportableException(self.context)
[...]
Regards,
Frank
More information about the Zope3-users
mailing list