Wichert Akkerman wrote:
I have an interesting problem in the world of Zope 2 and zcml: CMFCore
registers an handleDynamicTypeCopiedEvent subscriber which does
something that I want to prevent at all costs, so I am trying to make
sure it is not subscriber. That appears to be impossible!

I can not unsubscribe it, since the subscriber directive dynamically
creates a subscriber factory and registers that, so I have nothing to
call unregisterSubscriptionAdapter with.

I can not use zc.configuration to prevent the CMFCore zcml from being
loaded since I have no control over if its zcml is loaded before mine,
and if CMFCore gets to go first the zc.configuration exlusion trick no
longer works. This trick also has a downside: you can only exclude whole
files, which in this case would mean I would have to re-register half a
dozen subscribers by hand and pray that a future CMFCore would not add
another one and I'ld miss that.

Normally if all else fails you can resort to a monkey patch. Even that
does not work here since the original method is wrapped in an adapter
factory and then registered with the site manager, and at that point
using a monkey patch to replace the original method is no longer useful.

I have to admit that I'm baffled.

Subscribers and subscription adapters are particularly bad in this way, since they are unnamed and thus can't be "overridden", only amended to.

We've talked about an "off" switch for ZCML before. Given that we have a configuration machine that's capable of doing overrides based on discriminators, why couldn't we have support for negatives, e.g.

<unconfigure>
   <utility ... />
</unconfigure>

This could use a special _context that would record callables and discriminators, and then look for the corresponding callables/discriminators in the real context and remove them before that context was configured.

Martin

--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book

_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Reply via email to