1

我有一个具有多种 Dexterity 类型的自定义产品,其中一些被 setuphandler 用于创建站点结构。这在测试之外没有任何问题,但在测试中它一直失败:

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')

我确保在安装过程中导入包的配置文件:

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')

虽然它们在包的设置中被列为安装要求,但我也尝试了明确applyProfile的 onplone.app.dexterityquickInstallProduct,但由于某种原因,Dexterity FTI 在调用时似乎没有注册。

我正在使用 Plone 4.1、Dexterity 1.1 和 plone.app.testing 4.2

4

1 回答 1

1

正如 Mikko 所建议的那样,我将 setuphandler 配置从产品的 zcml 移到了 GenericSetupimport_steps.xml中,从而允许指定显式依赖项typeinfo

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

测试现在运行而不是在该applyProfile阶段失败,并且站点结构的测试表明它正在按预期设置。

再次感谢!

于 2012-08-01T00:49:05.877 回答