[Product-Developers] why is my view not used?
Maarten Nieber
maarten at usecm.com
Thu Dec 22 09:04:49 UTC 2011
Hi,
I switched from dexterity to archetypes, and have some problems getting my
template to use my view object. I am following the example.archetype example,
and would like to use my MessageView class in the template.
However, it is not using my view, but instead it is using SimpleViewClass.
Below I will paste all information to debug the problem, can anybody tell me
what I'm doing wrong (to be honest, I'm surprised that example.archetype does
not contain an example of a custom view class)
Thanks!
Maarten
My browser config is this one
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="elmolino.backend" >
<!-- IDefaultPloneLayer layer-based templates -->
<browser:page
for="elmolino.backend.interfaces.message.IInstantMessage"
layer="elmolino.backend.interfaces.message.IInstantMessageSpecific"
name="instantmessage_view"
class="elmolino.backend.content.message.MessageView"
template="instantmessage.pt"
permission="zope2.View"
/>
</configure>
view is
from Products.Five import BrowserView
class MessageView(BrowserView):
def blah(self):
import ipdb; ipdb.set_trace()
return "blah!"
and my template (instantmessage.pt) calls the view like this:
<div class="documentByLine">
Blah by <span tal:content="view/blah()" />
</div>
The error is this one
py2.6.egg/zope/traversing/adapters.py(50)traverse()
45 if hasattr(subject, '__getitem__'):
46 try:
47 return subject[name]
48 except (KeyError, TypeError):
49 pass
---> 50 raise LocationError(subject, name)
51
52 class Traverser(object):
53 """Provide traverse features"""
54
55 zope.interface.implements(ITraverser)
ipdb> name
'blah()'
ipdb> subject
<Products.Five.metaclass.SimpleViewClass from
/home/mnieber/code/cm/elmolino.buildout/src/elmolino.backend/elmolino/backend/br
owser/instantmessage.pt object at 0xcf11b6c>
More information about the Product-Developers
mailing list