[Grok-dev] Viewlet document for layouts

Leonardo Rochael Almeida leorochael at gmail.com
Tue May 13 13:36:08 EDT 2008


Viewlets are not some revolutionary new way of assembling things
toghether that is much better than macros and allow instantly powerful
and easy theming. It's just a way of moving part of the control of
deciding "what shows up where" from the code that invokes the macro to
the registration signature of the view.

When properly used, this allows more flexible and "evolvable"
software, specially with regards to the placement of snippets of code.
You no longer have to change your main macro to conditionally insert a
new piece.

Plone had powerful theming way before viewlets were available, but in
a sense it had to grow it's own standard of selecting what showed up
where. Some of it was done with a bunch of conditionals in (template!)
code. Some of it was done by looping through the contents of
properties set through the web. The use of widgets allowed all this
code to be streamlined, so that pieces of HTML code simply knew where
they wanted to insert themselves, instead of the template having to
drive everything.

Of course, the howto from Tim only shows you the simplest uses of
viewlet managers, and you can override other methods in the viewlet
manager for more flexible needs. But in the end, having a sensible
layout and theming is still the responibility of the developer using
Grok.

Whether it should be Grok's responsibility to provide a set of
defaults for layout and theming is a matter for futher discussion
which I will tacitly avoid for now :-)

Cheers, Leo

On Tue, May 13, 2008 at 1:15 PM, Sebastian Ware <sebastian at urbantalk.se> wrote:
> Thank's for putting the effort into writing the howto. I am however a real
> bone head.
>
> Is this really a revolutionary new way of doing things, or just a different
> way?
>
> I am really having difficulties understanding what the huge practical
> benefit is, but it sure raises the bar for a newbie who wants to understand
> how to create "proper" Grok apps.
>
> I was hoping for the ViewletManager to contain some hooks where you could
> dynamically assemble the page. Then I was hoping for a magic way of doing
> theming.
>
> I would have settled for a beautiful way of including subforms in the page,
> if this wasn't just as easy to do with macros and views.
>
> As I said earlier, I am probably missing something, but so far this looks
> like "same, same..." to me.
>
> Mvh Sebastian
>
> 10 maj 2008 kl. 01.23 skrev Tim Terlegård:
>
>> 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
>>
>> /Tim
>> _______________________________________________
>> Grok-dev mailing list
>> Grok-dev at zope.org
>> http://mail.zope.org/mailman/listinfo/grok-dev
>
> _______________________________________________
> 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