[Zope3-Users] Getting view result from Python

Christophe Combelles ccomb at free.fr
Wed Jun 27 08:31:00 EDT 2007


Thierry Florac a écrit :
>   Hi,
> 
> I'd like to get a view output from some Python code.
> 
> Actually, I don't have any problem if I use a page template with a
> simple <tal:x content="structure context/@@viewname" /> expression and
> return "self.template()" in Python.
> But it should certainly be "cleaner" and less expensive to get view
> output directly from Python code, which I don't actually manage to do...
> 
> So any advise to this probably simple problem would be welcome.

It depends on what you call a view,
if this is a BrowserPage, you have a __call__ method that returns the output.
so just call your view().
If this is a BrowserView, there is no __call__ because a BrowserView is not 
intended to be published as is. But you can have any method that returns HTML.
If this is a Viewlet or a ContentProvider, there is a render method that returns 
the output. (provided you first call the update method)

Christophe



More information about the Zope3-users mailing list