[Zope3-Users] Re: Sourcetext-mux

Philipp von Weitershausen philipp at weitershausen.de
Thu Nov 10 12:12:03 EST 2005


Frank Burkhardt wrote:
> Hi,
> 
> I found a code fragment in an example-application which enables a
> View-Object to render a SourceText using a renderer of the user's choice.
> 
> class ViewClass(object):
>     def render(self):
>         entry_text = zapi.createObject(None,
>                                        self.context.renderer,
>                                        self.context.text)
>         view = zapi.getView(removeAllProxies(entry_text), '', self.request)
>         result = view.render()
> 
> context.renderer contains a token of the 'SourceTypes'-Vocabulary (i.e.
> 'zope.source.rest'), context.text is the text to be rendered. The 'result' should be some
> kind of html (xhtml preferred :-) ).
> 
> Zope Complains about this code, telling me, not to use zapi.getView() but zapi.getMultiAdapter()
> but there's no hint, what parameters to use for getMultiAdapter.
> 
> Does anyone know the correct getMultiAdapter()-line - maybe with an explaination?

The equivalent line would be:

  zapi.getMultiAdapter((object, request), Interface, name=u'')

I just recently ported my wcsite package (available on
http://worldcookery.com/Downloads) to Zope 3.1. It has code very similar
to this one and provides examples of how the deprecation warnings are
correctly avoided in Zope 3.1+.

Best regards

Philipp



More information about the Zope3-users mailing list