Jens Vagelpohl wrote:
> Now, the main issue is still there, how to deal with tool wrapping when
> calling getUtility/queryUtility in trusted code. Doing it every time
> right after the call is stupid. I like Tres' hardline assertion that we
> must have it wrapped every time, automatically. This needs to be
> implemented somehow, maybe in Five as he suggests.
> How do we proceed?
Personally I like Tres idea as well. I had one idea so far that achieves
this without monkey-patching the functions in zope.component.
The idea is to use a specialized persistent component registry, that
does the needed AQ-wrapping.
This will however only give us AQ-wrapped local utilities, whereas those
registered with the global component registry wouldn't be wrapped. I
think this might be an acceptable trade-off.
Instead of creating a PersistentComponents registry in setuphandlers.py
in CMFDefault (or CMFPlone) we could use the following one:
from zope.component.persistentregistry import PersistentComponents
from Acquisition import aq_parent, Explicit
class Zope2PersistentComponents(Explicit, PersistentComponents):
def queryUtility(self, provided, name=u'', default=None):
utilities = super(Zope2PersistentComponents,
self).queryUtility(provided, name=name, default=default)
if utilities is not None:
if getattr(utilities, '__of__', None) is not None:
def getUtility(self, provided, name=u''):
utility = super(Zope2PersistentComponents,
if getattr(utility, '__of__', None) is not None:
I'm not sure about all the implications this has, so treat it with care
;) Also we would probably need to overwrite all the other methods that
return utilities like getUtilitiesFor, registeredUtilities, ... and we
would need to make a decision about how to handle adapters or subscribers.
Zope-CMF maillist - Zope-CMF@lists.zope.org
See http://collector.zope.org/CMF for bug reports and feature requests