在Plone5.1升级到Plone5.2过程中可能的坑
本文收集了在Plone5.1升级到Plone5.2过程中可能遇到的一系列坑以及解决办法.
1、不能导入IPossibleSite错误
错误产生的条件:
当你有定制的Dextertity内容类型,并且,你的代码中启用five.grok来代替ZCML来书写配置信息。
产生原因:
five.grok 依存的 IPossibleSite接口由原来zope.location包迁移到了zope.component包
3.7.1 (2009-11-18)
Move the IPossibleSite and ISite interfaces to zope.component as they are dealing with zope.component’s concept of a site, but not with location.
from zope.annotation.interfaces import IAttributeAnnotatable from zope.location.interfaces import IPossibleSite from zope import interface
解决办法:
编辑src/five/grok/components.py
将这行代码
from zope.location.interfaces import IPossibleSite
更改为:
from zope.component.interfaces import IPossibleSite
2、配置冲突错误
在Zope-4.1.1和zope.browserresource两个包中同时定义了 FileETag adapter,导致zcml配置冲突。
解决办法:取消Zope-4.1.1中重复加载的适配器定义。
编辑配置文件:
vi /home/demo/.buildout/eggs/Zope-4.1.1-py2.7.egg/Products/Five/browser/configure.zcml
注释adapter定义,如下代码9~10行所示:
<configure xmlns="http://namespaces.zope.org/zope" xmlns:browser="http://namespaces.zope.org/browser"> <interface interface="zope.browsermenu.interfaces.IMenuItemType" /> <include package="OFS" file="absoluteurl.zcml"/> <!-- adam <adapter factory="zope.browserresource.file.FileETag" /> --> <browser:view for="OFS.interfaces.IObjectManager" name="+" class=".adding.ContentAdding" permission="zope2.ViewManagementScreens" > <browser:page name="index.html" template="adding.pt" /> </browser:view>
3、要求Product.archetype依存性错误
错误产生条件:
加载三方包dexterity.membrane时出现。
错误产生原因:
dexterity.membrane依存于Products.membrane,而Products.membrane目前最新版4.0依然依存于Product.archetype,但Plone5.2.0后已经完全drop掉
Product.archetype和Product.ATContenttype。
File "/home/plone/workspace/Plone5sites/sites/src/Products.membrane/Products/membrane/at/interfaces.py", line 11, in <module>
from Products.Archetypes.interfaces import IBaseObject
ImportError: No module named Archetypes.interfaces
生活还要继续,我们不能退回到原始社会···
解决办法:
新建Products.membrane 5.0分支,drop 掉对Product.archetype的依存,并适当更新代码,使其完全支持Plone5.2.x。
4、Plone.PlonePAS导入错误:
File "/home/plone/workspace/Plone5sites/sites/src/Products.membrane/Products/membrane/setuphandlers.py", line 5, in <module>
from Products.PlonePAS.Extensions.Install import activatePluginInterfaces
zope.configuration.xmlconfig.ZopeXMLConfigurationError: File "/home/plone/workspace/Plone5sites/sites/src/Products.membrane/Products/membrane/exportimport/configure.zcml", line 17.2
File "/home/plone/workspace/Plone5sites/sites/parts/instance/etc/site.zcml", line 16.2-16.23
File "/home/plone/.buildout/eggs/Products.CMFPlone-5.2.0-py2.7.egg/Products/CMFPlone/configure.zcml", line 110.2-114.8
File "/home/plone/workspace/Plone5sites/sites/src/dexterity.membrane/dexterity/membrane/configure.zcml", line 9.2-9.37
File "/home/plone/workspace/Plone5sites/sites/src/Products.membrane/Products/membrane/configure.zcml", line 12.2-12.37
ImportError: No module named Extensions.Install
错误原因:
5.0.1 (2015-03-21)
Add a integrated test setup with codeanalysis and travis. For this moved Products folder to a src folder in order to follow the package structure expected by buildout.plonetest’s qa.cfg. [jensens]
Make patching of LDAPMultiPlugin explizit. Code using those must call Products.PlonePAS.ldapmp.patch_ldapmp with no parameters in order to activate the patches. [jensens]
Removed (optional) Archetypes Storage (used in past with CMFMember, which itself was long time ago superseeded by Membrane). Probably dead code. If theres someone out there needing it in Plone 5 please copy the code from git/Plone4 in your addon/project. [jensens]
Moved Extensions/Install.py functions to setuphandlers, kept BBB import for activatePluginInterfaces since this is imported by borg.localrole. [jensens]
错误处理:
使用 Products.membrane 5.0 branch