[z3-five] Using templates for content providers
Anton Stonor
anton at headnet.dk
Wed Aug 23 11:50:52 CEST 2006
How do I use a page template to render a content provider on Zope
2.9.3/Five 1.4?
My dummy content provider works (see below).
Now I want to use a page template to render the HTML fragment.
However, doing this ....
render = ZopeTwoPageTemplateFile('fragment.pt')
.... gives an error:
Traceback (innermost last):
Module ZPublisher.Publish, line 115, in publish
Module ZPublisher.mapply, line 88, in mapply
Module ZPublisher.Publish, line 41, in call_object
Module Products.five_hello_rdb.rdbview, line 41, in __call__
Module Shared.DC.Scripts.Bindings, line 312, in __call__
Module Shared.DC.Scripts.Bindings, line 347, in _bindAndExec
Module Shared.DC.Scripts.Bindings, line 1, in ?
Module Shared.DC.Scripts.Bindings, line 292, in _getTraverseSubpath
AttributeError: 'str' object has no attribute 'other'
It seems like the REQUEST attribute on the ZopeTwoPageTemplateFile
instance is a string-like ('<Special Object Used to Force Acquisition>')
where _getTraverseSubpath expects a request object.
Any ideas?
Another, related issue: Is it possible in ZCML to configure a page
template to be used for a content provider - like for normal views?
class StupidProfider(object):
zope.interface.implements(interfaces.IContentProvider)
zope.component.adapts(zope.interface.Interface,
browser.IDefaultBrowserLayer,
zope.interface.Interface)
def __init__(self, context, request, view):
self.__parent__ = view
self.request = request
self.context = context
def update(self):
pass
def render(self):
return "hello world"
/Anton
More information about the z3-five
mailing list