Am 01.12.2009, 07:52 Uhr, schrieb Jens Vagelpohl <>:

> Reminder: After this week (probably this coming Sunday) I plan on doing  
> the first CMF 2.2 beta, and creating the 2.2 release branch.

My CSS stuff won't make it into the beta. I would like to contribute some  
documentation on Yuppie's new add views but also continue the discussion.

As things currently stand Yuppie has implemented some very flexible add  
views that are almost entirely type definition-based. If a type definition  
has something in the new add view URL field then it will automatically be  
picked up for folder actions:

atool = getToolByName(self.context, 'portal_actions')
actions = atool.listFilteredActionsFor(self.context)
return actions.get("folder/add", {})

A really nice thing is support for schemaless, default add views that only  
require this URL of the form


This will get you a form with just a single field for the id.

Dedicated schema-based add views are trivial to add:

 from zope.formlib import form
 from Products.CMFDefault.formlib.form import ContentAddFormBase
 from MyApp.interfaces import IMyContentType

class MyAddView(ContentAddFormBase):
        form_fields = form.FormFields(IMyContentType)

May be all you need.

Otherwise there are examples for CMF Link and CMF Favourite.

We have a use case where we need the object creation without any kind of  
fields (id's are automatically assigned) and this is easy to implement

     def __call__(self):

You need to remember to return a new view or a redirect from the call  
which in this case is likely to be something other than an object's inital  
view. For example, returning  
self.request.response.redirect(self.request.HTTP_REFERER) lets you create  
lots of objects in a folder one after the other.        

Hooking everything together is, however, a bit clunky:


     <class class=".myproduct.MyAddView">

For the sake of clarity it would be nice to have a directive that ties  
this together. Particularly the juxtaposition of the adapter name (which  
has to be the same as the named content type factory utility) and the view  
acting as a factory is a definite possible source of confusion. And, while  
I much prefer the security declaration outside of the view class, the  
combination is a bit unintuitive.

I would find something like:


easier to work with.

I'm also not sure if the add view URL couldn't be simpler because the  
++add++ContentTypeId is a must, why this can't be interpolated either on  
type registration or in the add_action look-up. Is there any reason why  
this couldn't or shouldn't be the case?


Having finally taken the plunge into buildout I've been able to upgrade  
one of our projects onto Zope 2.12 and CMF 2.2 with no real problems just  
the odd "surprise". Thank you all very much for your help with Zope + CMF!

Charlie Clark
Helmholtzstr. 20
D- 40215
Tel: +49-211-938-5360
GSM: +49-178-782-6226
Zope-CMF maillist  -

See for bug reports and feature requests

Reply via email to