I have a Plone (4.2) form that is grokked. I want to have a dynamic source for a specific field. The relevant part of the schema:
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
)
this leads to:
ValueError: Invalid clone vocabulary
I tried every variant that is described in the plone dexterity developer manual. A method with decorator in combination with the source
attribute of RelationChoice
(see above) and a named Vocabulary class both with the same result.