Jim Fulton wrote:

> Jean-Marc Orliaguet wrote:
>> ...
>> With the '+' view described above, there is a default page attribute to
>> use for displaying the view ('index.html') and but no page attribute
>> explicitly assigned.
>> The following patch fixes the problem, but I'm afraid that I'm missing
>> something: are views supposed to have a '__page_attribute__' or not?
> They are only supposed to ave a page attribute if they are pages. :)
> The directive above creates a view *with pages*.  This means that the
> view itself should not a page and is not intended to be callable.
> Bottom line: views created this way are not callable and are not directly
> renderable.
> There's a bit more complexity than I'd like in these view directives.
> This is
> why, more and more, I tend to *define* views in Python and just
> register them
> with the adapter or view directive.  I still do often find it useful
> to register
> views with the view directive, mainly so I can avoid having to mention
> IBrowserRequest.
> Jim

OK, so the 'view' object set in page templates is not the object to call
for rendering the page.

All in all, I managed to render the '+' view by calling the 'template'
object and passing the 'view' as the instance parameter

>>> markup = template(instance=view)

instead of calling the 'view' directly with:

>>> markup = view()

This seems to be generic enough

Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to