[Grok-dev] Viewlet document for layouts

Tim Terlegård tim.terlegard at valentinewebsystems.se
Mon May 12 03:17:05 EDT 2008

On May 10, 2008, at 10:18 PM, Lennart Regebro wrote:

> On Sat, May 10, 2008 at 1:23 AM, Tim Terlegård
> <tim.terlegard at valentinewebsystems.se> wrote:
>> I've written an example application showing how viewlets can be used
>> to use the same layout on all pages and how to use different  
>> stylesheets
>> on different pages. It also shows how you can use grok.AddForm in a  
>> viewlet.
>> I uploaded the application to the grokapps section in svn:
>>   http://svn.zope.org/grokapps/SimpleViewletDemo/
>> And a how-to is written that tries to explain viewlets and the  
>> example
>> application:
>>   http://grok.zope.org/documentation/how-to/using-viewlets-for-layout/view
> Very nice. There is only one problem: What you actually do is that
> instead of making a view for an object, you use the same "main" view,
> and make the view a viewlet. This is neat, but that means that if you
> want to include somebody elses modules, those views will not get the
> layout.

That's true. I thought about this for a bit and the only solution I  
could come
up with would be to slightly patch the publisher so it looks for the  
of an IGlobalLayout utility. If it existed the publisher would ask  
that what to
do next. The utility would say that it should render layout.pt.

You'd then have the main content viewlet to just delegate update() and
render() to the adapted view which is the current view.

This would make it possible to surround any view with layout without
changing any existing view. But it would need to change the publisher.
Maybe there are better ways.

> I would in fact propose that this sort of technology becomes
> "standard" in Grok, and that Normal views are in fact viewlets for the
> main content. If not, the themehooks I did mean that you can impose
> this exact technology on normal views.

Don't follow here. What themehooks?


More information about the Grok-dev mailing list