[Zope3-Users] View with template

Dominik Huber dominik.huber at perse.ch
Mon Oct 31 02:51:58 EST 2005


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 (www.cbs.mpg.de - 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="view.pt"
>  />
>
>This is what I think this xml-statement should do:
>
>When http://zope/test/index.html is called, the template
>"view.pt" is evaluated which has access to the View-class
>"TestView".
>
>view.pt:
>--------
><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?
>  
>
If you use the the browser:form, browser:edit and/or browser:add 
directive your TestView will be mixed in automatically during the setup. 
In your example you are going to overwrite the __call__ method of the 
mixed-in base class which is invoking the template. If you like to 
overwrite the __call__ method, you have to call you base class too:

class TestView(object):
  def __call__(self):
    # do something else
    return super(TestView, self).__call__()

Regards,
Dominik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dominik.huber.vcf
Type: text/x-vcard
Size: 154 bytes
Desc: not available
Url : http://mail.zope.org/pipermail/zope3-users/attachments/20051031/d3e2fea3/dominik.huber.vcf


More information about the Zope3-users mailing list