[Grok-dev] grok.Layout and grok.Page
prsephton at gmail.com
Fri Oct 16 10:22:50 CEST 2015
I have been taking a closer look at the *grok.Layout* and *grok.Page*
components, and have some queries.
From what I can gather from the meager documentation, both
/grok.Layout/ and /grok.Page/ subclass /grok.View/, and are a way to
share a single layout view among many pages.
you can do
and from what I can gather, when *AView *or *BView *are rendered,
*MyLayer *will be rendered _*instead*_ of *AView* or *BView*. *AView
*and *BView *have a *content()* method which returns their rendered
content, so the layout can include the content in the rendered result.
In other words, when navigating to an instance of model *A*, the *AView*
gets called, which renders *MyLayout*, which includes *AView.content()*.
Is that correct? Do I have the right of it?
My real question is: what is the point of all this? In my most probably
limited understanding of what is going on, this looks like a really
complicated way of achieving something you can achieve more simply and
flexibly with other approaches, and I have to ask if this is true, what
reason *grok.Layout* has for existing.
The way I would generally approach the above issue would be:
class Index(grok.View): # My layout view
With the above, when navigating to model *A* or model *B*, the Index
view is rendered, which template renders the necessary page, including
/*provider:content*/. This /*provider:content*/ would be wither
*AViewlet *or *BViewlet* depending on the actual context.
From what I can tell, the difference between the /grok.Viewlet/
approach and the/grok.Layout/ approach is that /grok.Layout can
reference at most a single sub view/ (the /grok.Page/), while using a
Viewlet manager lets one use many content providers in the same
template, and the index page can be designed more like an index template
with a header section, a menu section, a content section, etc, etc.
Can someone please tell me what I am missing in all of this? Is the
*grok.Layout* really so limiting?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Grok-dev