[Zope3-dev] views have no __page_attribute__ ?
Jean-Marc Orliaguet
jmo at ita.chalmers.se
Tue Oct 4 09:23:43 EDT 2005
Hi!
I've encountered a problem when trying to render views (there is no
problem with rendering pages), but for instance with the '+' view that
is defined in app/container/browser/configure.zcml
<view
for="zope.app.container.interfaces.IContentContainer"
name="+"
menu="zmi_actions" title="Add"
class="zope.app.container.browser.adding.ContentAdding"
permission="zope.ManageContent"
allowed_attributes="addingInfo isSingleMenuItem hasCustomAddView">
<page name="index.html" template="add.pt" />
<page name="action.html" attribute="action" />
</view>
when called with:
markup = view()
['view' being the 'view' variable gotten from ZPT)
results in the following error message:
...
markup = view()
File "/home/jmo/Zope3/src/zope/app/publisher/browser/viewmeta.py",
line 445, in __call__
attr = self.__page_attribute__
AttributeError: '+' object has no attribute '__page_attribute__'
because the __call__ method of
zope.app.publisher.browser.viewmeta.simple expects views and pages to
have a page attribute:
def __call__(self, *a, **k):
# If a class doesn't provide it's own call, then get the attribute
# given by the browser default.
attr = self.__page_attribute__
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?
Index: app/publisher/browser/viewmeta.py
===================================================================
--- app/publisher/browser/viewmeta.py (revision 38719)
+++ app/publisher/browser/viewmeta.py (working copy)
@@ -275,6 +275,8 @@
required[pname] = permission
pages[pname] = attribute
+ if pname == 'index.html':
+ cdict['__page_attribute__'] = attribute
# This should go away, but noone seems to remember what to do. :-(
if hasattr(class_, 'publishTraverse'):
/JM
More information about the Zope3-dev
mailing list