plone.supermodel.serialzeModel with IContextSourceBinder vocabulary?

I have a schema field like

    gl_guideline_topics = schema.List(
        title=_("Guideline topics"),
        description=_("Guideline topics"),

which causes this NotImplementedError:

>>> print(serializeSchema(IGuideline))
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/ajung/sandboxes/onkopedia_buildout-plone5/eggs/plone.supermodel-1.6.3-py3.8.egg/plone/supermodel/", line 41, in serializeSchema
    return serializeModel(model.Model({name: schema}))
  File "/home/ajung/sandboxes/onkopedia_buildout-plone5/eggs/plone.supermodel-1.6.3-py3.8.egg/plone/supermodel/", line 45, in serializeModel
    return serializer.serialize(model)
  File "/home/ajung/sandboxes/onkopedia_buildout-plone5/eggs/plone.supermodel-1.6.3-py3.8.egg/plone/supermodel/", line 116, in serialize
    writeField(field, fieldset_element)
  File "/home/ajung/sandboxes/onkopedia_buildout-plone5/eggs/plone.supermodel-1.6.3-py3.8.egg/plone/supermodel/", line 70, in writeField
    fieldElement = handler.write(field, fieldName, fieldType)
  File "/home/ajung/sandboxes/onkopedia_buildout-plone5/eggs/plone.supermodel-1.6.3-py3.8.egg/plone/supermodel/", line 204, in write
    child = self.writeAttribute(attributeField, field)
  File "/home/ajung/sandboxes/onkopedia_buildout-plone5/eggs/plone.supermodel-1.6.3-py3.8.egg/plone/supermodel/", line 241, in writeAttribute
    return handler.write(
  File "/home/ajung/sandboxes/onkopedia_buildout-plone5/eggs/plone.supermodel-1.6.3-py3.8.egg/plone/supermodel/", line 437, in write
    raise NotImplementedError(
NotImplementedError: Choice fields with vocabularies not based on a simple list of values or a named vocabulary cannot be exported

vocabulary is in my case a method providing IContextSourceBinder. Wouldn't it make sense to just export the name of the source here (aka the method name, better: it's dotted name) instead of throwing an exception? Or is there something special complexity hidden here?

My guess is that the assumption is that when you don't use a named source (ie 'my.package.vocab') that the vocabulary could potentially contains a gazillion items.

I think you can do a named contextaware vocab and refer to it by name in the schema?

A named vocabulary is only "exported" through its name. A source in terms of a method must not be handled differently. In fact, I am working on a solution. Side note: goal is write a customer edit renderer based on the XML supermodel.

Fair enough :slight_smile:

I guess you could make the vocab a IVocabularyTokenized vocab, but I'm also interested what you'll come up with.

Have fun!