ZopeInLaunchpad/NoteOnZCML

Not logged in - Log In / Register

Revision 1 as of 2010-09-14 09:58:29

Clear message

Michael Hudson clarified some ZCA confusion (where some adapters were not working despite being registered with both the global site manager and via ZCML) with the following message:

This may not be news to anyone, but as far as I can see hasn't been
mentioned explicitly: the adaptor registrations in the ZCML take
effect when you (a) set up the FunctionalLayer (b) call
execute_zcml_for_scripts() (c) during appserver startup somehow.  So
if you only put the registrations in the ZCML and then run tests that
use cachedproperty but aren't in any layer -- and I bet we do this a
bit -- they will blow up.

AIUI, setting up the FunctionalLayer *replaces* the global site
manager, so if you just do the registration at import time, any tests
that use cachedproperty inside the FunctionalLayer -- and there are
certainly a lot of these! -- will fail.

If you do both, I don't know offhand why some tests would still fail.
Maybe some tests have overzealous tearDowns that rip out all adapter
registrations.

But I would say this: do adapter registrations in ZCML.  If you want
to use adaptation in cachedproperty, this means all tests using
cachedproperty need to be in the FunctionalLayer.  If this is too
onerous, then don't use adaptation in cachedproperty.

The complete thread.