[Zope3-Users] Alternatives to macros
ksmith93940-dev at yahoo.com
ksmith93940-dev at yahoo.com
Wed Sep 13 16:58:31 EDT 2006
I'm investigating alternatives to macros, the following appears to work, but
does anyone see anything particularly wrong or limiting with this implementation?
Thanks,
Kevin Smith
app.py
class PageView(BrowserView):
content = pagetemplate.ViewPageTemplateFile('page.pt')
def __call__(self):
view = zope.component.getMultiAdapter( (self.context, self.request), name="masterpage.html")
view.content = self.content
return view()
class NavbarContentProvider:
implements(IContentProvider)
adapts(Interface, IDefaultBrowserLayer, Interface)
def __init__(self, context, request, view):
self.context = context
self.request = request
self.__parent__ = view
def update(self):
pass
def render(self):
return '<a href="/">Home</a>'
configure.zcml
<browser:page
name="masterpage.html"
for="*"
template="masterpage.pt"
permission="zope.Public"
/>
<browser:page
for="*"
name="mppage1.html"
class=".app.PageView"
permission="zope.View"
/>
<adapter
factory=".app.NavbarContentProvider"
name="navbar.ContentProvider"
/>
masterpage.pt
<html>
<head><title>master.pt</title></head>
<body>
<div class="hd"><h2>master.pt</h2></div>
<div class="bd">
<div lass="nav">
<span tal:replace="structure provider:navbar.ContentProvider" />
</div>
<div class="content">
<div tal:replace="structure view/content" />
</div>
<div class="ft">master.pt footer</h2>
</body>
</html>
page.pt
<h2>page.pt</h2>
<div tal:replace="structure view/content" />
More information about the Zope3-users
mailing list