[z3-five] Re: Calling a browser:page from a browser view

Philipp von Weitershausen philipp at weitershausen.de
Sun Apr 2 23:22:32 CEST 2006


Alec Mitchell wrote:
> On 4/2/06, Andreas Jung <lists at andreas-jung.com> wrote:
>> --On 2. April 2006 14:21:18 +0200 Bernd Dorn <zope-mailinglist at mopa.at>
>> wrote:
>>
>>> On 02.04.2006, at 11:19, Andreas Jung wrote:
>>>
>>>> For a Plone content-type I defined a browser view and some browser
>>>> pages.
>>>> Inside a method of the browser view I would like to call at PT
>>>> configured
>>>> as browser page using:
>>>>
>>>>   return self.context.feedback_form(status=xxx, redirect=yyyy)
>>> a browser pagee is a multiadapter, so you have lookup it as such
>>>
>>> view = zope.component.getMultiAdapter((self.context, self.request),
>>> name='feedback_form')
>>>
>>> return view(status=xxx,redirect=yyy)
>> This does not work. getMultiAdapter() also need the interface as second
>> argument. But this also won't work. However you pointed me into the right
>> direction.
>>
>>  zapi.getView(self.context, 'feedback_form', self.request)
> 
> zapi.getView() is deprecated, but it is your only option in Zope 2.8
> (unless you are using Plone 2.5, in which case a small BBB patch has
> been applied to Zope 2.8 to give it a getMultiAdapter which is capable
> of looking up views).  Under zope 2.9+, you can and should use
> getMultiAdapter((obj, request), name='feedback_form') to lookup views.

Yes. Also, make sure the view has a proper Acquisition context:

view = zope.component.getWhatever(...)
view = view.__of__(context)
return view()

Philipp

P.S.: Please stop using zapi. It's stupid, it sucks and it'll be gone soon.



More information about the z3-five mailing list