I have a view defined for my content class that uses both view template and view class.
In zcml it looks like:


in 'xyz_body.pt' I have statements like:

<div tal:define="xyz_dict python: view.xyz_function();">

where 'xyz_function' is defined in 'XyzView' class.

Calling @@render from another view or directly by
URL in browser works, but when I'm using:
rnd = zapi.getMultiAdapter((self.xyz_instance, self.REQUEST), Interface, name='render')

rnd = getView(self.xyz_instance, 'render', self.REQUEST)

where 'xyz_instance' is a instance of content class (in ZODB)
that implements IXyz I get:

NameError Exception Value global name 'view' is not defined
Traceback (innermost last):
Module ZPublisher.Publish, line 114, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 40, in call_object
Module Products.XyzBase.XyzBase line 178, in save_form
Module Products.XyzModule.xyz_emailer, line 51, in save_data
Module Products.Five.browser.metaconfigure, line 403, in __call__
Module Shared.DC.Scripts.Bindings, line 311, in __call__
Module Shared.DC.Scripts.Bindings, line 348, in _bindAndExec
Module Products.PageTemplates.PageTemplateFile, line 110, in _exec
Module Products.PageTemplates.PageTemplate, line 104, in pt_render
<ImplicitAcquirerWrapper object at 0xb351b80c>
Module TAL.TALInterpreter, line 238, in __call__
Module TAL.TALInterpreter, line 281, in interpret
Module TAL.TALInterpreter, line 507, in do_setLocal_tal
Module Products.PageTemplates.TALES, line 221, in evaluate
URL: index
Line 1, Column 0
Expression: <PythonExpr view.xyz_function()>

<...cutted here...>

Module Products.PageTemplates.PythonExpr, line 70, in __call__
__traceback_info__: view.xyz_function()
Module <string>, line 2, in f
NameError: global name 'view' is not defined

How can I call such view from python code?
I'm using Zope 2.9.1.
In Zope 2.8.5 it was possible to use
context.xyz_function() instead of view.xyz_function() but now it causes

One more question - is it necessary to inherit from
Products.Five.BrowserView in view class?
I think that I've found somwhere that ZCML itself puts BrowserView
into base clases of view class...?

Maciej Wisniowski

Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to