AW: [Zope3-Users] pagelets vs. pages

Roger Ineichen dev at projekt01.ch
Wed Jun 27 07:07:04 EDT 2007


Hi Stephan, Herman

> Betreff: Re: [Zope3-Users] pagelets vs. pages
> 
> On Tuesday 26 June 2007 12:46, Hermann Himmelbauer wrote:
> > At first, thanks for your reply, this clears things up a 
> lot for me. 
> > The link to the Blog-entry above was also very valuable.
> 
> Great!
> 
> > What I still don't understand is how to implement a simple, 
> > quasi-static html-page. With browser:page I'd do it like this:
> >
> >   <browser:page
> >       name="index.html"
> >       for="myapp.interfaces.IMyApp"
> >       template="index.pt"
> >       layer="swarmfinder.layer.IMyAppLayer"
> >       permission="zope.Public"
> >       />
> 
> I'll note that Zope 3 does a lot of black magic to make this 
> directive work correctly.
> 
> > And the template "mypage1.pt" would e.g. use the "body" 
> macro and have 
> > some static content.
> 
> Right.
> 
> > In case of pagelets, I'd do it like this (correct me if I'm wrong):
> >
> >   <z3c:pagelet
> >       for="*"
> >       name="index.html"
> >       permission="zope.View"
> >       class=".MyAppPage1"
> >       layer="z3c.layer.pagelet.IPageletBrowserLayer"
> >       />
> >
> >     <z3c:template
> >       for=".MyAppPage1"
> >       layer="z3c.layer.pagelet.IPageletBrowserLayer"
> >       template="mypage1.pt"
> >       />
> >
> > And then I'd have to implement an interface and a class:
> >
> > class IMyAppPage1(zope.interface.Interface):
> >   pass
> >
> > class MyAppPage1(BrowserPagelet)
> >   implements(IMyAppPage1)
> >
> > This is a lot more code than with the browser:page example.
> > As a solution, I'm thinking about a magic "template" 
> directive in the 
> > z3c:pagelet namespace, e.g. something like that:
> >
> >   <z3c:pagelet
> >       for="*"
> >       name="index.html"
> >       permission="zope.View"
> >       template="mypage1.pt"
> >       layer="z3c.layer.pagelet.IPageletBrowserLayer"
> >       />
> 
> This example is longer than it needs to be. For starters, you 
> do not need the interface; in your example it serves no use. 
> Optionally, if you do not need to keep template registration 
> independent of view registration, the following will work as well:
> 
> class MyAppPage1(BrowserPagelet):
>     template = viewpagetemplatefile.ViewPageTemplateFile('mypage1.pt')
> 
> <z3c:pagelet
>     for="*"
>     name="index.html"
>     permission="zope.View"
>     class=".MyAppPage1"
>     layer="z3c.layer.pagelet.IPageletBrowserLayer"
>     />


Please don't use the z3c.viewtemplate package.

You can use the z3c.template package which offers
you a much better separated concept.

z3c.template and z3c.macro replaces the z3c.viewtemplate
package.

Regards
Roger Ineichen



More information about the Zope3-users mailing list