[z3-five] Is browser:addMenuItem and addingInfo() supposed to work?
Martin Aspeli
optilude at gmx.net
Sun Feb 18 13:12:56 CET 2007
Philipp von Weitershausen wrote:
> Martin Aspeli wrote:
>> 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:
> [snip]
>
> Next time, I suggest you paste the error traceback, because that's way
> more informative than a code snippet from Five that everybody can lookup
> by himself. Right now I had to guess what component it failed to lookup...
Yeah, sorry, was being lazy. The error is looking up the utility for the
IBrowserMenu.
>> Now, neither add_content nor zope.app.container.add is registered
>> anywhere (Products.Five or zope.*) that I can see.
>
> It's registered in zope.app/menus.zcml. This file is probably not
> available in Zope 2 (anymore):
>
> <menu
> id="zope.app.container.add"
> title="Add"
> description="Menu for objects to be added according to
> containment constraints"
> interface="zope.app.publisher.interfaces.browser.AddMenu"
> />
>
>> 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.
>
> add_content is old and no longer used in Zope 3.
>
> *Sigh*. This is *exactly* why I want to get rid of all of this useless
> code duplication in Five.
:)
>> I can add some registrations in Plone, or send patch to Five if we can
>> get it in time for Plone 3.
>
> For now I suggest you guys register zope.app.container.add yourself. Or,
> perhaps you register a variant and also regsiter your own adding view
> that refers to your variant.
Actually, I think it can't work anyway, because it first tries to look
for "add_content" which isn't registered anywhere either.
We made it work by looking up items registered for the
zope.app.publisher.interfaces.browser.AddMenu directly, i.e. not by
name. The <addMenuItem> directive falls back on this interface.
Martin
More information about the z3-five
mailing list