我有一个 grokked 的 Plone (4.2) 表格。我想有一个特定领域的动态来源。架构的相关部分:
from plone.directives import form
from z3c.relationfield.schema import RelationList, RelationChoice
from five import grok
from plone.formwidget.contenttree import ObjPathSourceBinder
@grok.provider(ISourceContextBinder)
def availableAttachments(context)
return ObjPathSourceBinder()
class IEmailFormSchema(form.Schema):
attachments = RelationList(
title = _(u'Attachments'),
description = _(u'Select and upload attachments.'),
default = [],
value_type = RelationChoice(
title =_(u"attachment"),
default = [],
# source = ObjPathSourceBinder() # this works
source = availableAttachments), # should do the same, but doesn't
required = False
)
这将导致:
ValueError: Invalid clone vocabulary
我尝试了plone dexterity 开发人员手册中描述的所有变体。带有装饰器的方法与(见上文)的source
属性RelationChoice
和命名的 Vocabulary 类的组合具有相同的结果。