Frank Burkhardt wrote:
> Hi,
> a short introduction first:
> I'm Frank Burkhardt, working at the Max Planck Institute in Germany. My
> employer wants a new website to replace the old one ( - yes,
> it looks really really ugly). We chose Zope3 to implement it.
> Maybe there will be one or two questions on the way which is the reason
> why I joined this list :-) .
> Here is the first one:
> I assigned a view to my brandnew content class:
>   <browser:page
>      for=".test.ITest"
>      name="index.html"
>      permission="zope.Public"
>      class=".test.TestView"
>      template=""
>   />
> This is what I think this xml-statement should do:
> When http://zope/test/index.html is called, the template
> "" is evaluated which has access to the View-class
> "TestView".
> --------
> <html metal:use-macro="context/@@standard_macros/view">
> <div metal:fill-slot="body">
>   <div tal:replace="view"></div>
> </div>
> </html>
> But whenever I define TestView.__call__ the template is not evaluated but
> the result of TestView.__call__ is returned directly.
> How can Zope be forced to use the template instead of __call__ing
> the TestView-Object?

Hi Frank,
I'll try to answer this (anyone find any errors in what I say please correct me :-)

Short answer:

You must call the template in your version of __call__,
the template is saved as the attribute index.
Call it like this:

    def __call__(self, ..., *args, **kw):
        return self.index(*args, **kw)

Long answer:

(note. The code for this is located in.

When your using th template directive in browser:page your class
gets wrapped in a wrapper class generated by the method SimpleViewClass (

The template gets assigned to the attribute index of the wrapper class,
and the class is use as the first base class.

The second base class of the wrapper class is a BrowserView derived class called simple and it's also defined in (
It is simple that defines the default behavior of __call__, that is
to call index (e.g. the template).

Now if you override the __call__ in your view class this behavior
is replace (because the view class comes before the simple class)
so you must implement the behaviour your self (e.g. your call needs
to call index).


Johan Carlsson          Tel: + 46 8 31 24 94
Colliberty              Mob: + 46 70 558 25 24
Torsgatan 72            Email: [EMAIL PROTECTED]

Zope3-users mailing list

Reply via email to