[Zope3-Users] z3c.form and subforms in an AddForm?

Stephan Richter srichter at cosmos.phy.tufts.edu
Wed Jul 4 16:58:23 EDT 2007


On Tuesday 03 July 2007 08:57, Matt Bowen wrote:
> from z3c.form.interfaces import IFormLayer
> from z3c.layer.pagelet import IPageletBrowserLayer
>
> class IMovingTargetBrowserLayer(IFormLayer, IPageletBrowserLayer):
>     """The moving target browser skin layer"""
>
> and registered it:
>     <!-- Moving Target Skin Layer -->
>   <interface
>       interface="movingtarget.layer.IMovingTargetBrowserLayer"
>       type="zope.publisher.interfaces.browser.IBrowserSkinType"
>       name="MovingTargetLayer"
>     />
>
> Then I have a browser skin:
>
> from z3c.formui import interfaces
> from movingtarget.layer import IMovingTargetBrowserLayer
>
> class IMovingTargetBrowserSkin(interfaces.IDivFormLayer,
> IMovingTargetBrowserLayer):
>     """The Moving Target Browser skin"""
>
> which I register:
>
>   <zope:interface
>       interface="movingtarget.skin.browserskin.IMovingTargetBrowserSkin"
>       type="zope.publisher.interfaces.browser.IBrowserSkinType"
>       name="MovingTargetBrowser"
>       />

The skin setup looks good.

>   <!-- layout template -->
>   <z3c:layout
>       for="*"
>       layer="movingtarget.layer.IMovingTargetBrowserLayer"
>       template="template.pt"
>       />

Also good.

> I have very simple edit and display classes:
>
> class NextActionEditForm(form.EditForm, layout.FormLayoutSupport):
>     """A simple edit form for Next Actions"""
>     label = u"Next Action Edit Form"
>     fields = field.Fields(INextAction)
>
> class NextActionDisplayForm(form.DisplayForm, layout.FormLayoutSupport):
>     """The display form for NextActions"""
>     fields = field.Fields(INextAction)

I am pretty sure that you need the FormLayoutSupport *before* the EditForm and 
DisplayForm in your inheritance order. The super-classes are read from right 
to left, and the layout support in FormLayoutSupport overrides attributes in 
DiaplayForm and EditForm.

> which I *think* I've registered edit and displays view with the following:
>
>   <!-- Edit Form -->
>   <z3c:pagelet
>       name="edit.html"
>       for="movingtarget.interfaces.INextAction"
>       class=".nextaction.NextActionEditForm"
>       layer="movingtarget.skin.browserskin.IMovingTargetBrowserSkin"
>       permission="zope.ManageContent"
>       />

Since you have issues with security, make the permission zope.Public for now.

>   <!-- Display Form -->
>   <z3c:pagelet
>       name="index.html"
>       for="movingtarget.interfaces.INextAction"
>       class=".nextaction.NextActionDisplayForm"
>       layer="movingtarget.skin.browserskin.IMovingTargetBrowserSkin"
>       permission="zope.Public"
>       />
>
>   <z3c:template
>       template="nextactionview.pt"
>       for=".nextaction.NextActionDisplayForm"
>       layer="movingtarget.skin.browserskin.IMovingTargetBrowserSkin"
>       />

Looks all good.

> But when I click on the name of my interpreter-made object, I get a 404.
> Anything obvious I'm missing?

I guess Hermann solved this problem already, suggestinbg that you need the 
++skin++ declaration.

Regards,
Stephan
-- 
Stephan Richter
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training


More information about the Zope3-users mailing list