class IUser(Interface):
userid = schema.TextLine(
title=_("User id"),
required=True,
constraint=validate_userid,
)
email = schema.TextLine(
title=_(u"Email"),
required=True,
constraint=validate_email
)
optional_type = schema.Choice(
title=_(u"User type"),
vocabulary="user_types",
required=True,
)
In a plone add-on I have something like this defined. The add-on need to be used for multiple websites. Sometimes the optional_type field is needed sometimes not. user_types is saved in portal_vocabularies. I want the field to be used only when the vocabulary exists and I want it to be ignored when the definition is missing.
I mean, I want this field to work for websites where it is used, but the user schema also to work in other case. For the moment I receive this error: ComponentLookupError: (<InterfaceClass zope.schema.interfaces.IVocabularyFactory>, 'user_types').
You can suggest any solution to skip this error without creating the vocabulary. Thanks.