Hello there.

Right after Chris came up with bfg:viewgroup, I decided to give it a
shot and check what would it take to get some layouting concepts
going.
So far I can tell it looks like z3 layout concepts.
You just group a bunch of, sorry, viewlets in a template and when that
template is rendered it will put pieces together.

Something like this:

site.pt

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";
     xmlns:tal="http://xml.zope.org/namespaces/tal";>
<head>
    <title>repoze.bfg viewgroup DEMO</title>
    <span tal:replace="structure provider('headers')" />
</head>
<body>
    <div id="content-wrapper">
        <div id="header">
            <p class="repoze">repoze.bfg</p>
            <p class="viewgroup">viewgroup<span class="demo">DEMO</span></p>
            <div id="tabs" class="f-right">
                <ul>
                    <span tal:replace="structure provider('tabsgroup')" />
                </ul>
            </div>
        </div>
        <div id="left-column" class="f-left">
            <span tal:replace="structure provider('leftboxes')" />
        </div>
        <div id="right-column" class="f-right">
            <span tal:replace="structure provider('rightboxes')" />
        </div>
        <div id="main-content-column">
            <span tal:replace="structure provider(viewname) "/>
        </div>
        <div class="clear"></div>
        <div id="footer">
            <a class="repoze"
href="http://static.repoze.org/bfgdocs/";>repoze.bfg docs</a>
        </div>
    </div>
</body>
</html>


As you can see there are a bunch of provider calls in there that will
render the necessary viewgroups.
The problem I see with this approach for example, is that if you want
to render something in the "main-content-column" you will need:

Two bfg:view registrations:

The first view will make use of the template I pasted above and the
second will provide the content itself. So to examplify:

Say you want to render a view at /my-view using the template above.
You would need:

configure.zcml

<bfg:view
   for=".models.IMyModel"
   name="my-view"
   view=".views.my_view_wrapper"
   />

views.py

def my_view_wrapper(context, request):
    from repoze.bfg.views import render_template_to_response
    from repoze.bfg.viewgroup import Provider
    provider = Provider(context, request)
    return render_template_to_response('templates/site.pt',

viewname='myview-content') <-- The markup provider. A bfg:view .

Note the viewname attr in there. It is there so the provider call
inside the template (site.pt)  can perform a view lookup that actually
renders some markup.
So we would need a second view registration so it renders some html:

def my_view(context, request):
    from repoze.bfg.views import render_template_to_response
    return render_template_to_response('templates/your_page_content.pt')
<-- This renders content w/o any style. Plain markup that will be
inserted into the main-content-column of the site.pt

And of course we'd need to register another bfg:view in configure.zcml:

 <bfg:view
   for=".models.IMyModel"
   name="myview-content"
   view=".views.my_view"
   />

So...Like I said i sounds like z3 layout registrations. Lots of
bfg:view registrations for the layout itself. Unnecessary view
wrapping so it gets rendered inside the layout renderer.

I was thinking in something simpler, maybe motivated by, sorry again,
z3c.layout.

So we would have something like:

<bfg:layout
    name="skinned"
    for=".model.IMyModel"
    layout=".views.layout"
    />

And then if one needs layout support for a view, a different
registration would be made. Something like:

<bfg:layeredview (Sorry for the lack of better word)
    name="my-view"
    for=".model.IMyModel"
    layout="skinned"
    view=".views.my_view"
    />

My motivations for doing such things by the way is that I believe most
people are not used to noble concepts like deliverance theming and etc
and still want to manage their layouts inside the application itself.
But looking at the current story, something makes me think that
deliverance is the way out :).

So, anyone? Ideas? Critics?

Best regards,
Fernando
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to