我们的某个网站的关系目录已经破损,我不知道如何修复它。
这就是我在日志中看到的内容:
2015-11-20T09:27:43 ERROR Zope.SiteErrorLog 1448018863.240.913599974037 http://www.example.com/folder/news-item/@@edit
Traceback (innermost last):
Module ZPublisher.Publish, line 138, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 48, in call_object
Module z3c.form.form, line 218, in __call__
Module collective.nitf.browser, line 64, in update
Module plone.dexterity.browser.edit, line 62, in update
Module plone.z3cform.fieldsets.extensible, line 59, in update
Module plone.z3cform.patch, line 30, in GroupForm_update
Module z3c.form.group, line 145, in update
Module plone.app.z3cform.csrf, line 21, in execute
Module z3c.form.action, line 98, in execute
Module z3c.form.button, line 315, in __call__
Module z3c.form.button, line 170, in __call__
Module plone.dexterity.browser.edit, line 26, in handleApply
Module z3c.form.group, line 126, in applyChanges
Module zope.event, line 31, in notify
Module zope.component.event, line 24, in dispatch
Module zope.component._api, line 136, in subscribers
Module zope.component.registry, line 321, in subscribers
Module zope.interface.adapter, line 585, in subscribers
Module zope.component.event, line 32, in objectEventNotify
Module zope.component._api, line 136, in subscribers
Module zope.component.registry, line 321, in subscribers
Module zope.interface.adapter, line 585, in subscribers
Module z3c.relationfield.event, line 76, in updateRelations
Module zc.relation.catalog, line 546, in unindex
Module zc.relation.catalog, line 556, in unindex_doc
Module zc.relation.catalog, line 622, in _remove
KeyError: 304600783
我已经尝试了几年前由@ martijn-pieters编写的The dreaded plone.relations IntId KeyError中的代码,但似乎不再有效,因为我无法找到任何名为IComplexRelationshipContainer
的接口。
任何提示?
答案 0 :(得分:1)
验证是否安装了plone.relations。
请参阅此处http://davidjb.com/blog/2010/10/bad-relationships-relationchoice-relationcatalog-and-removed-dexterity-content-in-plone,可能是此问题的解决方案。
例如
from zope.component.hooks import setSite
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManager import setSecurityPolicy
from Testing.makerequest import makerequest
from Products.CMFCore.tests.base.security import PermissiveSecurityPolicy, OmnipotentUser
from zope.component import getUtility
from zope.intid.interfaces import IIntIds
from zc.relation.interfaces import ICatalog
_policy=PermissiveSecurityPolicy()
_oldpolicy=setSecurityPolicy(_policy)
newSecurityManager(None, OmnipotentUser().__of__(app.acl_users))
portal = makerequest(app['Plone'])
setSite(portal)
intids = getUtility(IIntIds)
catalog = getUtility(ICatalog)
print [x.from_object for x in sorted(catalog.findRelations({}))]
答案 1 :(得分:1)
我想几年前我对类似的东西很不满意。
我发布了这个,一切都运行良好:
from Products.Five.browser import BrowserView
from Products.CMFCore.utils import getToolByName
from z3c.relationfield.event import updateRelations
from z3c.relationfield.interfaces import IHasRelations
from zc.relation.interfaces import ICatalog
from zope.component import getUtility
class View(BrowserView):
def __call__(self):
rcatalog = getUtility(ICatalog)
# Clear the relation catalog to fix issues with interfaces that don't exist anymore.
# This actually fixes the from_interfaces_flattened and to_interfaces_flattened indexes.
rcatalog.clear()
pc = getToolByName(self.context, 'portal_catalog')
brains = pc.searchResults(object_provides=IHasRelations.__identifier__)
for brain in brains:
obj = brain.getObject()
updateRelations(obj, None)
return "Catalog rebuilt for %s objects" % len(brains)