Sidnei da Silva wrote:
You explained a lot of stuff here, but you haven't backed your statement that installPackage cannot call registerPackage if it has not been called yet.
I never researched this. I tried to give you some pointers so that you could maybe look into it yourself.
I am worried that lots of people will be bitten by this issue and since the code to work around it is non-trivial to figure out, this will be a major source of pain.
All code that's not documented is non-trivial to figure out. I don't think this is particularly complicated in light of the other stuff we already do with tests and test setup and layers.
Note also, the @onsetup deferred method stuff is a performance optimisation that basically allows you to hook into the PloneTestCase layer. You don't need to do it that exact way, but it makes running tests faster.
My opinion is that we need a better answer to this question than 'just copy some random lines from borg and don't ask questions'.
Dude. That's not at all what I did, I tried to explain as best I could. If it's not good enough for you, go read the source, and if you can figure out a better way, propose a patch.
The product registration machinery is old and not trivial to figure out. A lot of semi-persistent black magic voodoo happens. I did help with supporting products-as-packages in ZopeTestCase, by replicating as closely as possible what's going on with installProduct() (and Stefan refactored my patch before 2.10.4 dropped).
Fundamentally, the <five:registerPackage /> cannot reliably do the install-product-in-control-panel dance. The ZCML is parsed too soon, and it breaks ZEO, for example. <five:registerPackage /> post Zope 2.10.4 now has a deferred list of products, which are loaded at a later point in time. However, ZopeTestCase does not auto-scan products, so you need installPackage(), much like you do installProduct().
In fact, ZopeTestCase doesn't cause Products.* products to be ZCML-processed either. Instead, the Plone ZCML layer calls Five's site.zcml which does this, but it doesn't read ZCML outside Products.* unless pulled in as a dependency. To get your package's ZCML to be read, you need to load it in a layer, which is what the @onsetup function does. So really, there is very little difference here, except that the PloneTestCase ZCML layer isn't magically aware of your package (unless it's a dependency of something in Products.* or you have a slug, but this isn't a very good way to write tests).
In almost all cases, you're going to need to load ZCML anyway. Perhaps installPackage() could load ZCML, but now it's getting messy: what if the package was already included, as a dependency of another package? What about overrides.zcml? meta.zcml? Do you really want these in the test?
Martin -- Acquisition is a jealous mistress _______________________________________________ Product-Developers mailing list [email protected] http://lists.plone.org/mailman/listinfo/product-developers
