我正在将一些旧产品更新到 4.x 代码库。
这是旧 Install.py 中的常见模式:
def install(self):
out=StringIO()
# Install CSS, JS and other GenericProfile stuff
setup_tool = getToolByName(self, 'portal_setup')
original_context = setup_tool.getImportContextID()
setup_tool.setImportContext('profile-Products.NoneMultiSelectionWidget:default')
setup_tool.runAllImportSteps()
但是, setup_tool.setImportContext() 方法不再存在。什么是正确的替换代码?我需要替换代码还是自动获取 GenericSetup XML 文件?
追溯:
- __traceback_info__: ('Products.NoneMultiSelectionWidget',)
File "/Users/moo/code/buildout-cache/eggs/Products.ExternalMethod-2.13.0-py2.6.egg/Products/ExternalMethod/ExternalMethod.py", line 234, in __call__
return f(*args, **kw)
- __traceback_info__: ((<PloneSite at /plone>,), {}, None)
File "/Users/moo/code/x/src/x/Products.NoneMultiSelectionWidget/Products/NoneMultiSelectionWidget/Extensions/Install.py", line 19, in install
setup_tool.setImportContext('profile-Products.NoneMultiSelectionWidget:default')
AttributeError: setImportContext