Le mercredi 27 juin 2007 à 14:31 +0200, Christophe Combelles a écrit :
> 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
> the output. (provided you first call the update method)
In fact it's a little bit more complicated...
What I have at first is a BrowserPage view, which is generally called
from a page template with "context/@@viewname" syntax, without any
But I need also to be able to get the same view output from a JSON call,
so that I can update a little bit of HTML code dynamically. I don't have
any problem when defining a template with the same syntax. But if I call
in python :
view = zapi.getMultiAdapter((myContext,myRequest), Interface,
I receive an error message :
__init__() takes at least 3 arguments (1 given)
So zapi.getMultiAdapter creates the view, but how can I initialize it
with it's required parameters (context and request) ?
Chef de projet intranet/internet
Office National des Forêts - Département Informatique
2, Avenue de Saint-Mandé
75570 PARIS Cedex 12
Mél : [EMAIL PROTECTED]
Tél. : +33 01.40.19.59.64
Fax. : +33 01.40.19.59.85
Zope3-users mailing list