Plone quickinstaller.installProduct';安装&x27;不需要的东西';甚至不存在。如何引发异常?
我的产品中有一个Plone quickinstaller.installProduct';安装&x27;不需要的东西';甚至不存在。如何引发异常?,plone,Plone,我的产品中有一个config.py,具有: DEPENDENCIES = ['bbbbbbbbbbbb'] #This doesn't exist 在我的setuphandlers.py中: for dependency in DEPENDENCIES: if not quickinstaller.isProductInstalled(dependency): quickinstaller.installProduct(dependency) 现在,我的门户网站_qu
config.py
,具有:
DEPENDENCIES = ['bbbbbbbbbbbb'] #This doesn't exist
在我的setuphandlers.py
中:
for dependency in DEPENDENCIES:
if not quickinstaller.isProductInstalled(dependency):
quickinstaller.installProduct(dependency)
现在,我的门户网站_quickinstaller的内容选项卡中有一个bbbbbbbbbbbb条目。(http://localhost:8080/Plone/portal_quickinstaller/manage_main)
如果依赖项不存在,我应该怎么做才能使依赖项部分“抱怨”(引发异常,不管怎样)?谢谢
编辑:我发现了一个使用
quickinstaller.getProductVersion的黑客:如果什么都没有出现,它就不存在。还有别的办法吗?我想这取决于你为什么会有一个不存在的产品
通常情况下,您不会在这里进行测试-您会将依赖项放在setup.py中,然后如果产品不存在,构建就会失败
但是,如果您有一个产品可能会使用另一个产品(例如,SQLAlchemy需要一个或多个python DBAPI蛋,但没有特定的蛋),然后,我认为您需要执行通常的操作:即使用try/except在产品中包装某个模块的导入,如果导入失败,则不进行安装。您可以使用以下方法:
def install_dependencies(site):
"""Install required products"""
qi = getToolByName(site, 'portal_quickinstaller')
for product in DEPENDENCIES:
if not qi.isProductInstalled(product):
if qi.isProductInstallable(product):
qi.installProduct(product)
else:
raise "Product %s not installable" % product
声明DEP的常规方法是使用metadata.xml
:
<metadata>
<dependencies>
<dependency>profile-plone.app.iterate:plone.app.iterate</dependency>
</dependencies>
</metadata>
当然,这只有在您尝试安装的产品具有通用安装配置文件时才有效,但除了最旧的配置文件外,其他所有配置文件都具有通用安装配置文件。@MatthwmWilkes:这就是问题所在,我的安装非常异构。但我会把你的解决方案留给新的。谢谢
<metadata>
<dependencies>
<dependency>profile-plone.app.jquerytools:default</dependency>
<dependency>profile-archetypes.referencebrowserwidget:default</dependency>
<dependency>profile-plone.app.imaging:default</dependency>
<dependency>profile-plone.app.registry:default</dependency>
<dependency>profile-plone.portlet.collection:default</dependency>
</dependencies>
</metadata>