我有一个具有多种 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.dexterity
和quickInstallProduct
,但由于某种原因,Dexterity FTI 在调用时似乎没有注册。
我正在使用 Plone 4.1、Dexterity 1.1 和 plone.app.testing 4.2