from plone.autoform.interfaces import IFormFieldProvider
from plone.namedfile import field as namedfile
from plone.rfc822.interfaces import IPrimaryField
from plone.supermodel import model
from zope.interface import alsoProvides
from zope.interface import provider


@provider(IFormFieldProvider)
class IImageField(model.Schema):
    """We need to override the default image field so that we can interpret an
    empty string as NOT_CHANGED.
    """

    image = namedfile.NamedBlobImage(title="Image", description="", required=True)


# The equivalent of setting marshal:primary="true" on the field in the schema:
alsoProvides(IImageField["image"], IPrimaryField)
