pyramid_layout and configure.zcml

26 views
Skip to first unread message

Andrey Skobeldin

unread,
Oct 10, 2014, 5:04:32 AM10/10/14
to pylons-...@googlegroups.com
Hello!

I'm trying to use pyramid_layout package for declarative configuration of my app. I would like to configure it only in configure.zcml file. 

Here it is:

<configure xmlns="http://pylonshq.com/pyramid"

    <include package="pyramid_zcml" />
    <include package="pyramid_layout" file="meta.zcml"/>

    <static
        name="static"
        path="static"
    />

    <!-- layouts -->
    <lat:layout
        name="test"
        layout=".layouts.AppLayout"
        template="templates/layouts/layout1.pt"
    />

    <!-- default view -->
    <view
        view=".views.my_view"
        renderer="templates/home.pt"
        lat:layout="test"
    />

    <view
        name="two"
        view=".views.my_view2"
        renderer="templates/mytemplate2.pt"
    />

</configure>


When I called the default view - got an exception:

NameError: main_template

 - Expression: "main_template"
 - Filename:   ... o\python_test\pyramid7\myzcml1\myzcml1\templates\home.pt
 - Location:   (line 4: col 25)
 - Source:     <metal:block use-macro="main_template">
                                       ^^^^^^^^^^^^^
 - Arguments:  repeat: {...} (0)
               renderer_name: templates/home.pt
               req: <Request - at 0x4a96be0L>
               request: <Request - at 0x4a96be0L>


File home.pt:

      xmlns:metal="http://xml.zope.org/namespaces/metal" >
<metal:block use-macro="main_template">
<div metal:fill-slot="content">
<h1>It is home view</h1>
<p>Hello home.pt template</p>
<p>Project is: ${project}</p>
</div>
</metal:block>
</html>

What I did wrong in my code? So, is it possible to use pyramid_layout in such manner? 

BTW, if I use request.layout_manager.use_layout("test") in view.my_view code - it works fine! 

But I want do this work  just in configure.zcml. Is it possible?

bismigalis

unread,
Oct 16, 2014, 3:10:15 PM10/16/14
to pylons-...@googlegroups.com
I think that package needs to support configuring through zcml and pyramid_layout just don't support this.

пятница, 10 октября 2014 г., 13:04:32 UTC+4 пользователь Andrey Skobeldin написал:
Reply all
Reply to author
Forward
0 new messages