[Grok-dev] pagelets/layouts in grok
cklinger at novareto.de
Mon Feb 23 10:22:34 EST 2009
i worked during the last weeks on the grok/pagelet story.
I have now a megrok.pagelet  *prototype* which allows us to
set up Layout´s and Pagelet´s. For more information please
take a look into the README  and the tests  of the
> Some design thoughts I have:
> * it's reasonable to start with megrok.pagelet with a Pagelet class. We
> can experiment with things there before possibly folding this into
> Grok itself.
This is done in the megrok.pagelet.Pagelet class. Works like a view but
in __call__ method it renders the view into the layout.
> * it should always be possible to swap out grok.View with Pagelet and
> have things work exactly the same without doing any extra work.
> A Pagelet is a view which does one extra thing - wrap the layout
> thingy around whatever it's viewing.
I agree, but we have to make sure that we have a corresponding layout
for that view. Maybe we register an "empty default" layout. Or we search
for layout for the view, if we get one then return the rendred layout,
if not return the normal view.
> * One exception: don't bother supporting the 'render()' method for now.
> This is going to be factored out grok.View anyway. Just support
> regular template-based rendering.
> * There is a new directive to indicate the layout template on the
> pagelet. grok.layout()? Now I get fuzzy - I don't recall exactly how
> this works with ZCML pagelets. How are these things registered and
> looked up? Someone needs to do some research and
> describe what's going on, and make some proposals for Grok. We should
> be inspired by the current pagelet story but we don't have to
> slavishly follow it either - I think we need more than just a simple
> translation of the ZCML directives to Grok.
I think we don´t need a layout directive, because the Layout is
registerd on a specific context and layer. The view itself looks for the
Layout based on context and layout.
> * The rule that things will just work by simply swapping View for
> Pagelet implies that we want there to be a default layout
> that does absolutely nothing. This means that grok.layout (or
> whatever it is called) needs to have a default that does
> * We need to consider interaction with layers. Can perhaps a layer
> define a layout that's used for everything that is in that layer?
> In this case we might not need a grok.layout directive for
> Pagelet at all, but instead only allow its use on layers. Perhaps
> this makes no sense at all though - I haven't through this
> through at all. How would this work with extensions overriding
> layouts, multiple layers in a skin, etc?
I think this works if you register the Layout like this:
> * I think it'd be nice if eventually grok.View could gain pagelet-like
> functionalities and we can do away with any extension. This kind
> of functionality is useful to have out of the box, but shouldn't
> break existing applications.
> * We need to answer questions like: how would an extension override the
> layout of a core project? How can an extension introduce a layout
> while the core didn't have one yet (it used the default layout)?
If we register a default layout for Interface. Then it should be
possible to register the *project layout* exactly for the project app.
Please see this as a starting point for further investigations.
Maybe someone can have a look on this and give some feedback.
Sorry for my english and bad grammer.
Btw. is there a grok sprint in the near future?
Thanks for your help...
More information about the Grok-dev