[Zope-CMF] Re: Add forms and menus

Martin Aspeli optilude at gmx.net
Sun Jul 13 14:21:50 EDT 2008


Charlie Clark wrote:

> This is probably necessary anyway. I'm not sure whether it's right to  
> try and go straight to z3c.form. My understanding is that there isn't  
> a great deal of difference between the two libraries so hopefully an  
> implementation could live with both. I don't think that everyone has  
> moved onto z3c.form - certainly that wasn't my impression at  
> Europython. It would be nice to have a formlib based CMF 2.2 and I  
> think I now understand most of this well enough to contribut. We could  
> possibly  onto z3c.form in 2.3 which might have replaced zope.formlib  
> in Zope by then.

I doubt that formlib will be replaced by z3c.form. Rather, it just seems 
that everyone prefers to work with the latter and so the former is 
becoming less relevant.

They are definitely different, and don't share any code as far as I 
know, but if you know one, moving to the other is pretty trivial. 
z3c.form also has good (if a bit too abundant) documentation.

Thus, if CMF hasn't yet picked a form library in a release, then you 
could try to learn from Plone's mistakes and not jump on a sinking ship. :)

>> How about we use a naming convention that's linked to the factory  
>> that's persisted in the FTI, i.e. we look for a view called "add- 
>> <factory_name>" and link to that if it's available.
> 
> You might as well stick with actions if you're going to do that. I've  
> been experimenting with the following
> 
> portal_type = self.request.form.get('portal_type')
> at = getToolByName(self.context, 'portal_actions')
> actions = at.listFilteredActionsFor(self.context)
> addable = actions.get('add', [])
> for a in addable:
>      if a['id'] == portal_type:
> 	return request.response("%s/%s" (%self.context.absolute_url(),  
> a['url']))
> 
> It's workable but so easy to break as it relies on "add" actions  
> having the same name as the portal_type. It makes much more sense to  
> me to have this on the type info: if I ask the type tool for the  
> factory, surely I can also ask it for the view?

You mean we have an action on the FTI object with category 'add' and 
name == FTI name/portal_type? That still means having to get that link 
right, though (a typo in the FTI name or a rename of the FTI makes it 
break), and I question whether you ever need all the other info that 
actions provide. We already have ways to control add permissions and 
other filters for what's addable where.

Martin


-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book



More information about the Zope-CMF mailing list