[Grok-dev] RFC: Masterpage implementation without macros

kevin at mcweekly.com kevin at mcweekly.com
Sun Apr 15 16:26:55 EDT 2007

Quoting Lennart Regebro <regebro at gmail.com>:

> On 4/12/07, Kevin Smith <kevin at mcweekly.com> wrote:
>> We're using grok for the base of the relaunch of our newspaper website.
>> I'm not fond of macros, so here is an alternate masterpage
>> implementation that I think is fairly easy to grok.  This sort of
>> strategy might also apply in a template neutral environment. Please let
>> me know what you think.
> This strategy works. It only has one drawback as a generic strategy,
> and that is that your object needs to implement all the methods used
> to fill in the master template, especially the things in the header,
> such a title() and a method for adding extra css, and one for extra
> javascript. For a generic system this ends up as being quite a lot of
> methods.

Thanks for your reply. As far as implementing methods, I'm  
experimenting with simple inheritance and mixins.

class Master:

     def title(self):
         return  "My Website"
     def header(self):
         return "The header"
     def footer(self):
         return "All rights reserved"

class Movies(Master):
     def header(self):
         return "The Movies"

For javascript/css I cheat and use zc.resourcelibrary. :)

I'll find out shortly how well this scales, I'm implementing this on a  
full-featured portal.

> I still haven't had the time (or, well, the energy, rather) to mock up
> what I and Martijn discussed before which would make a better generic
> strategy, but don't let that worry you. The two would be quite
> compatible. :-)

I'm looking forward to this. :)

> -- 
> Lennart Regebro: Zope and Plone consulting.
> http://www.colliberty.com/
> +33 661 58 14 64

Kevin Smith

More information about the Grok-dev mailing list