[Grok-dev] Re: Re: viewlets, pagelets and friends
Darryl Cousins
darryl at darrylcousins.net.nz
Mon Aug 13 04:55:35 EDT 2007
Hi Luis,
On Mon, 2007-08-13 at 00:44 +0200, Luis De la Parra wrote:
> Hi Darryl,
>
> What would you think of changing this:
>
> Darryl Cousins wrote:
> [...]
> > class Index(mars.view.PageletView):
> > grok.name('index.html')
> > grok.context(zope.app.folder.interfaces.IFolder)
> > grok.require(path.to.mypermissions.View)
> >
> > class IndexTemplate(mars.template.TemplateFactory):
> > grok.context(Index)
> > grok.template('templates/index.pt')
> >
>
> to this:
>
> class Index(mars.view.PageletView):
> grok.name('index.html')
> grok.context(zope.app.folder.interfaces.IFolder)
> grok.require(path.to.mypermissions.View)
> grok.template('templates/index.pt') # <<
>
> or maybe
>
> class Index(mars.view.PageletView):
> grok.name('index.html')
> grok.context(zope.app.folder.interfaces.IFolder)
> grok.require(path.to.mypermissions.View)
> grok.template('templates/index.pt') # <<"Content"-template
> grok.layout('templates/page.pt') # <<"Layout"-template
>
> ?
> cheers. luis
The use of the pagelet concept makes it imperiative to be able to define which interface the
registered template provides (usually IPageTemplate or ILayoutTemplate) and
also to be able to define a name (possible required by a view) and thirdly to be
able to define the macro to be used from within the template (introducing
`z3c.macro`_).
For these reasons the ``grok.template`` has been reinvented in `mars.view`_ to
tell the grokker that the view should look up a named template. And templates are now
registered as any other component using grokkers. The difference being that
the component class is a factory - and therefore named as such.
A template is not bound to a view as an attribute. Instead the view will look up a template
in the component registry, a template can then be easily reused by many views (as layout
templates usually are) and a view can be created to look up as many templates as it may
require (by name or interface depending on design and needs).
Hope that helps.
Look out for http://www.tfws.org.nz/mars/z3c - coming soon.
Best regards,
Darryl
>
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev
More information about the Grok-dev
mailing list