我正在尝试删除我正在测试的Plone网站。但是,当我删除它时,我收到错误。
从控制台:
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 OFS.ObjectManager, line 540, in manage_delObjects
Module OFS.ObjectManager, line 391, in _delObject
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 OFS.subscribers, line 101, in dispatchObjectWillBeMovedEvent
Module zope.container.contained, line 153, in dispatchToSublocations
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 OFS.subscribers, line 101, in dispatchObjectWillBeMovedEvent
Module zope.container.contained, line 153, in dispatchToSublocations
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 OFS.subscribers, line 101, in dispatchObjectWillBeMovedEvent
Module zope.container.contained, line 153, in dispatchToSublocations
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 OFS.subscribers, line 101, in dispatchObjectWillBeMovedEvent
Module zope.container.contained, line 153, in dispatchToSublocations
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 OFS.subscribers, line 101, in dispatchObjectWillBeMovedEvent
Module zope.container.contained, line 153, in dispatchToSublocations
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 Products.CMFCore.CMFCatalogAware, line 271, in handleContentishEvent
Module Products.CMFCore.CMFCatalogAware, line 76, in unindexObject
Module Products.CMFCore.CatalogTool, line 280, in unindexObject
Module Products.CMFPlone.CatalogTool, line 354, in uncatalog_object
Module Products.ZCatalog.ZCatalog, line 508, in uncatalog_object
Module Products.ZCatalog.Catalog, line 383, in uncatalogObject
Module Products.PluginIndexes.common.UnIndex, line 286, in unindex_object
Module Products.PluginIndexes.UUIDIndex.UUIDIndex, line 98, in removeForwardIndexEntry
Module z3c.relationfield.relation, line 79, in __cmp__
Module z3c.relationfield.relation, line 82, in _sort_key
Module z3c.relationfield.relation, line 31, in from_path
Module plone.app.relationfield.monkey, line 14, in get_from_object
Module z3c.relationfield.relation, line 110, in _object
Module zope.component._api, line 169, in getUtility
ComponentLookupError: (<InterfaceClass zope.intid.interfaces.IIntIds>, '')
页面只显示:
(<InterfaceClass zope.intid.interfaces.IIntIds>, '')
我确实在事件订阅者中使用了IIntIds,我想知道这可能是问题所在。
当特定内容类型的对象转换时,将创建另一个内容类型的另一个对象,并使用IIntIds实用程序从创建的对象“获取”关系值。 RelationValue附加到对象转换的relatedItems。 创建的对象也有relatedItems,我得到对象转换的关系值,并将其附加到创建对象的relatedItems。
在configure.zcml中:
<subscriber
for="my.product.myobject.MyObject
Products.DCWorkflow.interfaces.IAfterTransitionEvent"
handler=".events.myObjectTransitioned" />
在events.py中:
def myObjectTransitioned(obj,event):
....
action = event.status['complete']
if action == 'activate':
.....
try:
new_obj = api.content.create(container=OtherObjs,portal_type='my.object.anotherobject',
title=a_concat_title, id=a_concat_title)
int_ids = getUtility(IIntIds)
obj.relatedItems.append(RelationValue(int_ids.getId(new_obj)))
new_obj.relatedItems.append(RelationValue(int_ids.getId(obj)))
obj.reindexObject()
new_obj.reindexObject()
except:
print "failed creation"
我遇到了一个类似的问题,其中一个答案提到没有安装plone.app.relationfield或plone.app.intId。我有plone.app.relationfield(RelationValue)和plone.app.intId(plone.app.intid:install utility)。
我基本上这样做,以便new_obj可以通过方便地调用to_object从obj(转换对象)获取信息,反之亦然。但是,我猜这是导致这个错误,我应该使用back_obj的后向引用从obj获取信息?
答案 0 :(得分:2)
基本上阻止您删除站点的是每次触发的事件(运行您提到的麻烦代码)。为防止出现这种情况,我建议您执行以下操作:
$ cd {buildout-dir}
$ bin/zopepy
> from transaction import commit
> app._delObject('Plone', suppress_events=True)
> commit()
一般情况下,不建议对Plone站点内的对象执行此操作,因为这样可以防止portal_catalog更新并导致其他副作用。但是当你整体删除网站时,没关系。