[Grok-dev] global_adapter method no longer gets adapts from factory annotation.

Jan-Carel Brand lists at opkode.com
Thu Mar 15 12:55:13 UTC 2012


On Thu, 2012-03-15 at 13:40 +0100, Jan-Carel Brand wrote:
> Hi folks
> 
> I'm hoping you can elucidate some changes that were introduced into
> grokcore.component from version 2.0.
> 
> 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.

<big snip>

An obvious workaround has just dawned on me after sending this email.

If global_adapter doesn't explicitly get the "adapts" value from the
factory, I must provide it explicitly myself.

So if I do the following, my adapters are registered and the validations
work.

> grok.global_adapter(ProcurementExplanationValidator,
> adapts=ProcurementExplanationValidator.__component_adapts__)

> grok.global_adapter(UniquenessValidator,
> adapts=UniquenessValidator.__component_adapts__)
> 
It however *feels* wrong :D

Is there a better, more elegant way of doing this? I'd still like to
know how global_adapter is now supposed to get the "adapts" parameter it
it's not explicitly passed in.

Also, if the docstring of global_adapter says that "adapts" is gotten
from the annotation, but it isn't, then I guess that line needs to be
removed or the intention cleared up.

JC



More information about the Grok-dev mailing list