我在 4.3 站点上遇到了同样的问题,在一个多次复制/移动的对象中......
短篇故事
我禁用了修改第 57 行的规则(Traceback 指出的那个):
Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module plone.app.contentrules.browser.assignments, line 57, in __call__
KeyError: '/mysite/aFolder/aSubFolder'
由此:
get_assignments(storage[r]).remove(path, None)
对此:
if path in assignments:
get_assignments(storage[r]).remove(path, None)
** 很长的故事 **
该补丁被应用覆盖管理内容规则视图。这是需要的zcml
<browser:page
for="plone.contentrules.engine.interfaces.IRuleAssignable"
name="manage-content-rules"
class=".contentrules_patch.PatchedManageAssignments"
layer="my.abb.browser.interfaces.IMyAppLayer"
permission="plone.app.contentrules.ManageContentRules"
/>
这是 contentrules_patch.py 中包含的类
class PatchedManageAssignments(ManageAssignments):
def __call__(self):
"""
"""
request = aq_inner(self.request)
form = request.form
if not 'form.button.Delete' in form:
return super(PatchedManageAssignments, self).__call__()
context = aq_inner(self.context)
assignable = IRuleAssignmentManager(context)
storage = getUtility(IRuleStorage)
status = IStatusMessage(self.request)
rule_ids = form.get('rule_ids', ())
path = '/'.join(context.getPhysicalPath())
for r in rule_ids:
del assignable[r]
assignments = get_assignments(storage[r])
if path in assignments:
get_assignments(storage[r]).remove(path, None)
status.addStatusMessage(_(u"Assignments deleted."), type='info')
return self.template()