Comment 2 for bug 274655

Revision history for this message
Devin (devin.charityfinders.org) wrote :

Also, if the grouping directive you create doesn't subclass `zope.configuration.config.GroupingContextDecorator` and/or doesn't have similar '__getattr__' functionality (and still satisfies the interface contract of `zope.configuration.interfaces.IGroupingContext`), then Zope will terminate with an AttributeError message complaining about the lack of a 'factory' attribute.

Instead of attempting to find the needed methods on its 'context' member, perhaps the various stack item class instances should find the objects with the methods they need by searching up the tree until an object that implements `zope.configuration.interfaces.IConfigurationContext` is found. Something like:

    def __getConfigurationContext(self):
        context = self.context
        while not IConfigurationContext.implementedBy(context):
            context = context.context
        return context

... and replacing `self.context` with `self.__getConfigurationContext()` (where appropriate) should work (I haven't tested it), and would still allow grouping directives to contain attributes like 'action' and 'factory'.