FB a écrit :
On Sat, Jan 06, 2007 at 01:35:35AM +0100, Christophe Combelles wrote:
I define the following interfaces:
Then I would like to configure a class Test to to be both a FooContainer and a
<implements interface=".interfaces.IFooContainer" />
<implements interface=".interfaces.IBarContainer" />
Then I define AddMenuEntries for Foo and Bar implementations.
This does not work and as a result I only get Foo in the Add Menu. If I switch the two
implements zcml directives, I obviously get only Bar.
Is there a solution to configure a class to be both a FooContainer and a BarContainer with
constraintment ? (I would like to avoid dependencies between Foo, Bar and Test.)
IHMO you should use the containers()-statement on IFoo and IBar instead of
contains() on their containers. Even if the contains-constraints of
IFooContainer and IBarContainer would be merged somehow on the Test-class,
it wouldn't behave as you expect:
The contains()-statement can be read as "mustn't contain anything but...".
Mixing those two constraints depending on two different contained interfaces
would result in "Can't contain anything.".
This makes sense, if you have classes, relying on self.values() returning
but objects implementing the given interface.
I understand there is an inconsistency between these two interfaces, and this is
not a correct solution.
But using just containers() on content objects doesn't prevent their containers
from displaying everything in the Add Menu.
It just prevents from adding these objects in other containers.
Is there a way to restrict the Add Menu list of a specific container?
(actually maybe I shouldn't bother with this, since the zmi and the addmenu is
not an end solution for an application?).
Zope3-users mailing list