← Back to team overview

launchpad-dev team mailing list archive

Re: Need some help to understand weirdness with the propertycache API

 

On 14 September 2010 02:30, Michael Hudson <michael.hudson@xxxxxxxxxxxxx> wrote:
...
> 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.

Ah ha, this explains a lot!

> 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.

Yes, I think I'll rip out the adaption parts of propertycache, but
it's very useful to understand what was going on anyway.

I've put your explanation on the wiki, I hope that's okay.

  https://dev.launchpad.net/ZopeInLaunchpad/NoteOnZCML

(I didn't have a very good idea of *where* to put it on the wiki, so
it's probably in an awful place right now. Anyone, please feel free to
move it without the slightest worry of offending me.)

Thanks Michael, and Robert and Jono too for their responses.

Gavin.



References