[Zope3-Users] Weird behaviour of ViewPageTemplateFile()
Albertas Agejevas
alga at pov.lt
Thu Apr 10 10:21:53 EDT 2008
On Thu, Apr 10, 2008 at 04:08:43PM +0200, Martin J.Laubach wrote:
> > Well, it's called a *View*PageTemplate for a reason :-) If the
> file is
> > really empty and you do not need to pass any arguments to it (view,
> > context, request), use a plain PageTemplateFile
>
> No, of course it's not empty and it needs the parameters. Nor does
> the view really look as trivial as the example. That was the minimal
> test case for the behaviour I could come up with.
>
> I still don't understand how the naming / storage of a variable
> holding the page template can influence the page rendering process.
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. Otherwise you would have to pass
these arguments by hand. When using PageTemplateFile you would have
to pass the args like this:
pt = PageTemplateFile("file.pt")
result = pt(arg1, arg2, arg3=value, arg4=value)
Then the positional args would be available in the TAL namespace as args,
and the keyword arguments would be available as options:
<tal:block define="arg1 python:args[0];
arg2 python:args[1];
arg3 options/arg3;
arg4 options/arg4;" />
Arguably, the keyword arguments are a bit less ugly.
HTH,
Albertas
More information about the Zope3-users
mailing list