I have a custom product with a number of Dexterity types, several of which are used by a setuphandler to create the site structure. This works without any issues outside of testing, but within tests it keeps failing:
Traceback (most recent call last):
[snip]
File "/opt/ctcc_plone/src/ctcc.model/ctcc/model/setuphandlers.py", line 52, in setupStructure
random = createSiteFolder(portal, 'ctcc.model.servicefolder', 'Randomisation', 'random')
File "/opt/ctcc_plone/src/ctcc.model/ctcc/model/setuphandlers.py", line 35, in createSiteFolder
return createContentInContainer(context, type, title=title, id=id)
File "/opt/ctcc_plone/eggs/plone.dexterity-1.1-py2.7.egg/plone/dexterity/utils.py", line 166, in createContentInContainer
content = createContent(portal_type, **kw)
File "/opt/ctcc_plone/eggs/plone.dexterity-1.1-py2.7.egg/plone/dexterity/utils.py", line 112, in createContent
fti = getUtility(IDexterityFTI, name=portal_type)
File "/opt/ctcc_plone/eggs/zope.component-3.9.5-py2.7.egg/zope/component/_api.py", line 169, in getUtility
raise ComponentLookupError(interface, name)
ComponentLookupError: (<InterfaceClass plone.dexterity.interfaces.IDexterityFTI>, 'ctcc.model.servicefolder')
I'm ensuring the package's profile is imported during setup:
class CTCCModelSandboxLayer(PloneSandboxLayer):
defaultBases = (PLONE_FIXTURE,)
def setUpZope(self, app, configurationContext):
import ctcc.model
self.loadZCML(package=ctcc.model)
def setUpPloneSite(self, portal):
self.applyProfile(portal, 'ctcc.model:default')
While they're listed as install requirements in the package's setup, I've also tried an explicit applyProfile
on plone.app.dexterity
, as well as quickInstallProduct
, but for some reason the Dexterity FTI's don't appear to be registered at the time they're called.
I'm using Plone 4.1, Dexterity 1.1, and plone.app.testing 4.2
As suggested by Mikko, I moved the setuphandler configuration from the product's zcml and into a GenericSetup import_steps.xml
instead, allowing for an explicit dependency on typeinfo
to be specified:
<?xml version="1.0"?>
<import-steps>
<import-step
id="ctcc-setup"
title="Additional CTCC setup"
handler="ctcc.model.setuphandlers.setupVarious"
version="20120731"
>
<dependency step="typeinfo" />
</import-step>
</import-steps>
Tests now run instead of failing during the applyProfile
stage, and the tests of the site structure show it's being set up as expected.
Thanks again!