[z3-five] Is browser:addMenuItem and addingInfo() supposed to work?
Martin Aspeli
optilude at gmx.net
Fri Feb 16 02:28:24 CET 2007
Hi,
I've seen reports of people making this work, but I'm struggling. I've
got an add view (formlib AddForm) and an add menu item like so:
<browser:addMenuItem
title="Foo"
factory="my.package.Foo"
view="my.package.Foo"
permission="cmf.AddPortalContent"
/>
I then want to list all addable views (in fact, I'm trying to make Plone
respect add-menus and ultimately add forms, at least in the case where
an add menu item can be linked to an old-fashioned CMF).
However, I get ComponentLookupErrors, because adding.py in Five does this:
def addingInfo(self):
"""Return menu data.
This is sorted by title.
"""
container = self.context
result = []
for menu_id in (self.menu_id, 'zope.app.container.add'):
if not menu_id:
continue
for item in getMenu(menu_id, self, self.request):
extra = item.get('extra')
if extra:
factory = extra.get('factory')
if factory:
factory = zope.component.getUtility(IFactory,
factory)
if not checkFactory(container, None, factory):
continue
elif item['extra']['factory'] != item['action']:
item['has_custom_add_view']=True
result.append(item)
result.sort(lambda a, b: cmp(a['title'], b['title']))
return result
self.menu_id is from here:
class ContentAdding(Adding, SimpleItem):
menu_id = "add_content"
Now, neither add_content nor zope.app.container.add is registered
anywhere (Products.Five or zope.*) that I can see. The latter is
provided in a test in zope.app.publisher. The former is nowhere to be
found. Unless I provide both, I can't see how this won't fail every time.
I can add some registrations in Plone, or send patch to Five if we can
get it in time for Plone 3.
Martin
More information about the z3-five
mailing list