[Zope3-Users] z3c:layout - not working with z3c.form.EditForm

kevin gill kevin at movieextras.ie
Tue Jan 29 09:24:35 EST 2008


I am having a problem configuring a layout template. It works with
z3c.form.DisplayForm but not with z3c.form.EditForm.

formdemo works fine for me. It seems to use an identical approach.

Thanks, Kevin

-------------------------------------------------------------------
Here is the details to recreate the problem:

http://localhost:8080/++skin++MySkin/@@index.html does not use the template.

http://localhost:8080/++skin++MySkin/@@index2.html uses the template.

I added these packages (setup.py):

    'z3c.pagelet',
    'z3c.layer',
    'z3c.form',
    'z3c.formui',

I configured these packages:

  <!-- Add your own component registrations here -->
  <include package="zope.viewlet" file="meta.zcml"/>
  <include package="zope.contentprovider" />
  <include package="zope.viewlet" />

  <include package="z3c.form" file="meta.zcml" />
  <include package="z3c.macro" file="meta.zcml" />
  <include package="z3c.pagelet" file="meta.zcml" />
  <include package="z3c.template" file="meta.zcml" />

  <include package="z3c.form" />
  <include package="z3c.formui" />

  <include package="z3c.layer.pagelet"/>
  <include package="z3c.macro" />
  <include package="z3c.pagelet"/>

I created a new layer (layer.py):

    from z3c.form.interfaces import IFormLayer
    from z3c.layer.pagelet import IPageletBrowserLayer

    class IMyBrowserLayer(IFormLayer, IPageletBrowserLayer):
        pass

And a new skin (skin.py):

    import z3c.formui.interfaces
    import layer

    class IMyBrowserSkin(z3c.formui.interfaces.IDivFormLayer,
                           layer.IMyBrowserLayer):
       pass

I registered the above:

    <interface
        interface=".layer.IMyBrowserLayer"
        type="zope.publisher.interfaces.browser.IBrowserSkinType"
        />

    <interface
        interface=".skin.IMyBrowserSkin"
        type="zope.publisher.interfaces.browser.IBrowserSkinType"
        name="MySkin"
        />

I create a layout (template.pt):

    <h1>TEMPLATE</h1>
    <tal:block replace="structure provider:pagelet" />

I register it:

    <z3c:layout
        for="*"
        layer=".layer.IMyBrowserLayer"
        template="template.pt"
        />

I create two new pages (browser.py):

    from z3c.form import form

    class IndexForm(form.EditForm):
        pass

    class IndexForm2(form.DisplayForm):
        pass

I match these with templates (index.pt and index2.pt):

    index.pt

    index2.pt

I register the new views:

   <z3c:pagelet
        name="index.html"
        for="*"
        permission="zope.Public"
        layer=".layer.IMyBrowserLayer"
        class=".browser.IndexForm"
        />

    <z3c:template
        template="index.pt"
        for=".browser.IndexForm"
        layer=".layer.IMyBrowserLayer"
        />

    <z3c:pagelet
        name="index2.html"
        for="*"
        permission="zope.Public"
        layer=".layer.IMyBrowserLayer"
        class=".browser.IndexForm2"
        />

    <z3c:template
        template="index2.pt"
        for=".browser.IndexForm2"
        layer=".layer.IMyBrowserLayer"
        />




More information about the Zope3-users mailing list