Inheritance of form schema hints

Hi Plone Developers!

I currently learned that schema hints are not inherited by chield classes of a schema.

Let's assume a simple case:

class IEmailAddress(model.Schema):

    read_permission(  check_spam='inqbus.mc.emailaddress.read_check_spam' )
    write_permission( check_spam='inqbus.mc.emailaddress.write_check_spam' )
    check_spam = schema.Bool(default=True,
                             title=_("check spam"),
                             required=False,
                             )

class ISpecialEmailAddress(IEmailAddress)

    check_virus = schema.Bool(default=True,
                             title=_("check virus"),
                             required=False,
                             )

The permissions set on the field "check_spam" are working perfectly on forms utilizing IEmailAddress but not on forms utilizing ISpecialEmailAddress.

Let us further assume that this behavior is intended - since it exhibits an inbuild logic: If the form hints were to be inherited - how to get rid of them in client classes?

We have an application with quite a bit of inheritence of schemas. So it would be nice to know a way to inherit the schema hints to a child schema, explizitly. Is there an API for it? If not please do not elaborate! I can fiddle that pice of code myself, but I prefere to use code already existing.

Any help appreciated

Volker

Welcome to inheritance!

Build guess: can you split up schema definition and specific form constraints as in your case into a pure schema class and a constraints class? You could use the constraints class as mixin for the particular form where you need it and just use the inherited schema class without the constraints class inside your derived class?

-aj

I think this as a kind of bug/missing feature. May you file an issue in the plone.dexterity issue tracker please?

Done:

That is not possible since the form hints require a direct reference to the fields in the same schema class.

class IEnabledByAdminHints(model.Schema):

    read_permission(enabled_by_admin='inqbus.mailcenter.view_enabled_by_admin')
    write_permission(enabled_by_admin='inqbus.mailcenter.edit_enabled_by_admin')

class IEnabledByAdmin(model.Schema, IEnabledByAdminHints):

    """
    Schema for enabled by admin
    """
    enabled_by_admin = schema.Bool(
        title=_(u"Enabled By Admin"),
        default=True
    )

zope.configuration.config.ConfigurationExecutionError: <type 'exceptions.ValueError'>: The directive plone.autoform.security.read-permissions applied to interface inqbus.mailcenter.interfaces.mc.IEnabledByAdminHints refers to unknown field name enabled_by_admin

Or did I get your idea wrong?