[z3-five] Calling a view from a view currently fails

Jan-Wijbrand Kolman jw at infrae.com
Wed Mar 9 17:18:13 MET 2005


Hello,


I just now checked in the 'jw-calling_view_fails'. The test case that I added to 
this branch currently fails.

The CallingOtherView view class, registered for ISimpleContent, tries to lookup 
and another view (called 'condor.html') also registered for ISimpleContent, like so:

class CallingOtherView(BrowserView):

     def render(self):
         view = zapi.getView(self.context, 'condor.html', self.request)
         return view()

The lookup seems to succeed, however calling the view found fails with a 
KeyError on 'view'. Apparently, the template used for the 'condor.html' view 
does not have the 'view' namespace available.

I think the reason for not having the 'view' namespace available in this 
situation, lies in 'pagetemplatefile.py', line 52 - 64:

     def _pt_getContext(self):
         view = self._getContext()
         try:
             root = self.getPhysicalRoot()
             here = view.context
         except AttributeError:
             # self has no attribute getPhysicalRoot.
             # This typically happens when the template has
             # no proper acquisition context. That means it has no view,
             # since that's the normal context for a template in Five. /regebro
             root = self.context.getPhysicalRoot()
             here = self.context
             view = None
         ...

Not sure if I understand the comment in there, but apparently there's no 
getPhysicalRoot attribute found on context in this particular case, hence 'view' 
is set to None, which results no 'view' namespace being added to the 
pagetemplate's context.

I guess this needs to be solved in Five, but I don't yet have any clue where to 
start looking... Anyone an idea? Or maybe do I have it all wrong here?


regards,
jw

-- 
Jan-Wijbrand Kolman
jw at infrae.com


More information about the z3-five mailing list