我正在尝试删除我正在测试的 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>, '')
我确实在事件订阅者中使用了 IIntId,我想知道这是否可能是问题所在。
当特定内容类型的对象转换时,将创建另一种内容类型的另一个对象,并且我使用 IIntIds 实用程序从创建的对象中"获取"关系值。 关系值将追加到对象转换的相关项中。 创建的对象也有相关项目,我获取对象转换的关系值并将其附加到所创建对象的相关项目。
在 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(转换对象)获取信息,反之亦然。 但是,我猜这导致了此错误,我应该使用反向引用来new_obj从 obj 获取信息?
基本上阻止您删除网站的是每次触发的事件(运行您提到的麻烦代码)。为了防止这种行为,我可以建议执行以下操作:
$ cd {buildout-dir}
$ bin/zopepy
> from transaction import commit
> app._delObject('Plone', suppress_events=True)
> commit()
通常,不建议对 Plone 站点中的对象执行此操作,因为例如,这也会阻止portal_catalog更新并导致其他副作用。但是,当您删除整个网站时,这并不重要。