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):

    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,
        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.



Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to