[Zope-CMF] Re: Add forms and menus
yuppie
y.2008 at wcm-solutions.de
Wed Jul 16 06:20:57 EDT 2008
Hi Martin!
The discussion seems to go into the right direction. Just a few notes:
Martin Aspeli wrote:
> So, let me try to summarise what I think we're saying here:
>
> - My type has a form like:
>
> class MyAddForm(CMFBaseAddForm):
> fields = form.Fields(IMyType)
> portal_type = 'My type'
Here you are mixing up content type with portal type. We can't hardcode
the portal type if we want to use the add form for renamed/derived
portal types as well.
> - The base form knows to look at self.factory_name to look up the
> factory when it does the create() call.
create() needs to know the portal type, not just the factory name.
> - The base add form implements ICMFAddForm
>
> - I register the form as a normal <browser:page />, with the convention
> that the name is the same as the factory name
>
> - The FTI has an 'addview' property, which by convention is set to
> string:${folder/absolute_url}/@@add/${portal_type}
>
> - The @@add view looks like
>
> class AddView(BrowserView):
> implements(IPublishTraverse)
>
> def publishTraverse(self, request, name):
> portal_types = getToolByName(self.context, 'portal_types')
> fti = getattr(portal_types, name)
> factory = fti.factory
> addview = getMultiAdapter((self.context, request), ICMFAddForm,
> name=factory)
> addview.portal_type = name
> return addview
Above you wanted to use self.factory_name inside the form, now you set
addview.portal_type.
We definitely have to pass the portal type to the view. If we have to
look up the factory name in publishTraverse, we might want to pass it to
the view as well.
Cheers,
Yuppie
More information about the Zope-CMF
mailing list