global_adapter method no longer gets "adapts" from factory annotation

Bug #960097 reported by JC Brand on 2012-03-20
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Jan Wijbrand Kolman

Bug Description

I'm creating this ticket after the mailing list discussion on this topic:

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

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

Here is the error's traceback:

The two clashing adapters are two validators that I am registering via
grok.global_adapter. See here:

So, looking inside grokcore/component/ I see
that there are some changes made between 1.9 and 2.0 that cause this

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

My grokcore versions:

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

JC Brand (jcbrand) on 2012-03-20
description: updated

the tests were very cleverly hiding the issue indeed. It has been fixed.

Changed in grok:
assignee: nobody → Jan Wijbrand Kolman (janwijbrand)
importance: Undecided → High
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers