[Zope3-Users] Weird behaviour of ViewPageTemplateFile()
Martin J. Laubach
mjl at laubach.at
Thu Apr 10 14:59:36 EDT 2008
>> > ViewPageTemplate must be in the view's namespace, and it magically
>> > fishes out the view, view's context and request, and makes them
>> > available in the TAL namespace.
>>
>> Ah, so there _IS_ heavy magic involved here. Thanks for
>> clarifying that, I was already doubting my sanity!
>
>
> This is exactly the same magic that methods use. ViewPageTemplateFiles
> are, like functions, meant to be used as methods and to be bound to
> instances.
Okay, then this leads me to the strong suspicion that what I'm
(mis)using ViewPageTemplateFiles for is the wrong way to attack
the problem.
What I'm doing is something along the lines of
class MyView(BrowserView):
def __call__(self):
pagename = somehow_compute_new_page_name(self.request,
self.context)
pt = ViewPageTemplateFile(pagename)
return pt.__get__(self, self.__class__)()
but quite obviously, that's not how it's meant to be used, is it...
Perhaps I need a radically different approach?
Cheers,
mjl
More information about the Zope3-users
mailing list