Plone- ComponentLookUpError 阻止我删除 Plone 站点?

Plone- ComponentLookUpError is preventing me from deleting Plone site?

我正在尝试删除我正在测试的 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,我想知道这是否可能是问题所在。

当特定内容类型的对象转换时,会创建另一个内容类型的对象,并且我 "get" 使用 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:安装实用程序)。

我这样做基本上是为了 new_obj 可以通过方便地调用 to_object 从 obj(转换对象)获取信息,反之亦然。但是,我猜这是导致此错误的原因,我应该为 new_obj getting information from obj?

使用反向引用

基本上阻止您删除站点的是每次触发的事件(运行 您提到的麻烦代码)。为防止这种行为,我建议您执行以下操作:

$ cd {buildout-dir}
$ bin/zopepy
> from transaction import commit
> app._delObject('Plone', suppress_events=True)
> commit()

一般来说,不建议对 Plone 站点中的对象执行此操作,因为这会阻止 portal_catalog 更新并导致其他副作用。但是当你把网站整体删除的时候,就没有关系了。