Comment 0 for bug 960097

Revision history for this message
JC Brand (jcbrand) wrote :

----------------------------------------------------------------------------------------------------------
I'm creating this ticket after the mailing list discussion on this topic:
https://mail.zope.org/pipermail/grok-dev/2012-March/

Most of the text that follows come straight from my first email to the mailing list.
----------------------------------------------------------------------------------------------------------

I'm developing with Plone/dexterity/z3c.form, currently using
grokcore.component 1.9 and trying to see if I can use a newer version
instead.

With grokcore.component > 1.9 I however get a
ConfigurationClonflictError, due to two global nameless adapters.

Here is the error's traceback: http://pastie.org/3600511

The two clashing adapters are two validators that I am registering via
grok.global_adapter. See here: http://pastie.org/3600499

So, looking inside grokcore/component/directive.py:global_adpter I see
that there are some changes made between 1.9 and 2.0 that cause this
breakage.

If you look at the registration of my adapters, I don't provide "adapts"
or "provides" kw args to global_adapter. The docstring of method
global_adapter itself says:

> If omitted, this information is deduced from the annotation on the
> factory.

In grokcore.component < 1.9, this happened explicitly:

> if adapts is None:
> adapts = getattr(factory, '__component_adapts__', None)

But since 2.0 that code is now gone. What happens now is that my two
global adapters are registered against adapts=None and provides=None.
And of course, since they don't have names, they registration clashes.

Looking at the SVN log, I see that Martijn introduced the mentioned
change in global_adapter with the following explanation:

> r104104 | faassen | 2009-09-15 18:30:24 +0200 (Tue, 15 Sep 2009) | 6
> <snip>
>
> Upgrade to use the new Martian 0.12. This allowed us to
> significantly simplify the way the context directive worked. It
> also made us realize it's bad form to use directives in the
> implementation of a directive - directive.bind.get() should only
> be used during Grok time, never during import time.

To be honest, I don't see know how the above should result in the changes in
global_adapter.

My grokcore versions:

> '/home/jc/.buildout/eggs/martian-0.14-py2.6.egg',
> '/home/jc/.buildout/eggs/grokcore.rest-1.2-py2.6.egg',
> '/home/jc/.buildout/eggs/grokcore.view-2.6.1-py2.6.egg',
> '/home/jc/.buildout/eggs/grokcore.security-1.5-py2.6.egg',
> '/home/jc/.buildout/eggs/grokcore.component-2.4-py2.6.egg',