Rocky wrote:
On Feb 23, 3:50 pm, Martin Aspeli <[EMAIL PROTECTED]> wrote:
yuppie wrote:
Maybe I'm missing something. But wasn't a major goal of
five.localsitemanager to return acquisition wrapped tools?
That was my understanding, too. I thought this would just mean
aq_base'ing the utility and aq-wrapping it back into the context (the
portal root). Without this, we start requiring users of the interface to
know when aq wrapping is needed and do it explicitly with __of__() which
I think we agreed was unacceptably detailed and ugly. :)

Alright, I've gone ahead and put code in place for this (albeit a bit
naively) with r72810.  The next question is whether we should be doing
the same with adapters and subscribers as well (even though this
doesn't affect the whole tools-getting-acquired-properly issue).

I'm a bit uneasy about the implementation. With Acquisition.ImplicitAcquisitionWrapper(base, parent) it seems you're wrapping all utilities, even those that don't inherit from acquisition and potentially don't want acquisition. Even worse, you give them an *implicit* acquisition wrapper.

I think _wrap() should be changed to:

    def _wrap(self, comp):
        """Return an aq wrapped component with the site as the parent.
        if Acquisition.interfaces.IAcquirer.providedBy(comp)
            parent = Acquisition.aq_parent(self)
            if parent is None:
                raise ValueError('Not enough context to acquire parent')

            base = Acquisition.aq_base(comp)
            comp = base.__of__(parent)
        return comp

This way, only objects that inherit from one of the Acquisition base classes will be wrapped at all.

-- -- Professional Zope documentation and training
Next Zope 3 training at Camp5:

Zope-CMF maillist  -

See for bug reports and feature requests

Reply via email to