[Grok-dev] Using adaptation without running a web application.

Martijn Faassen faassen at startifact.com
Thu Jan 22 04:41:01 EST 2009


Vincent Fretin wrote:
> You have a simple example in archgenxml:
> http://svn.plone.org/svn/archetypes/ArchGenXML/trunk/src/archgenxml/plone/config_py.py
> It uses zope.component and only
> component.provideAdapter(ConfigPyView)
> at the end to register the adapter.

Manually calling zope.component's API is quite reasonable for a smaller 
application. It's also a common way to set things up in tests.

For larger applications composed out of many components, what 
zope.configuration adds are things like:

* configuration and registration happening later than import time. 
Things happening as a side-effect of an import can lead to rather 
difficult ordering problems and headscratchers.

* conflict detection if multiple registrations are made for the same 
interfaces and names. No silent overrides.

* conflict resolution and overrides if you structure your ZCML include 
story in certain ways.

And of course using it will also provide for better compatibility with 
other Zope 3 code. :)

Grok for quite a while used a separate configuration phase (grok-time) 
but the zope.component APIs. This meant conflict resolution didn't work 
and people could mistakenly override things that they didn't wish to. At 
some point we switched over to use zope.configuration, also to gain 
better compatibility with Zope 3.

So while I don't want to diminish the value of simplicity in the direct 
registration strategy, I do believe grokcore.component adds more than 
just the Grok-style declarations.

Regards,

Martijn




More information about the Grok-dev mailing list