# -*- test-case-name: nevow.test -*- # Copyright (c) 2004-2005 Divmod, Inc. # See LICENSE for details. from zope.interface import Attribute from zope.interface.interface import InterfaceClass, Interface class ITyped(Interface): """Typeds correspond roughly to tags in HTML, or with a complex type, more than one tag whose input is processed and coerced as a unit. """ def coerce(val, configurable): """Coerce the input 'val' from a string into a value suitable for the type described by the implementor. If coercion fails, coerce should raise InputError with a suitable error message to be shown to the user. 'configurable' is the configurable object in whose context the coercion is taking place. May return a Deferred. """ label = Attribute("""The short label which will describe this parameter/properties purpose to the user.""") description = Attribute("""A long description which further describes the sort of input the user is expected to provide.""") default = Attribute("""A default value that may be used as an initial value in the form.""") complexType = Attribute("""Whether or not this Typed is a "simple" type and the infrastructure should render label, description, and error UI automatically, or this type is "complex" in which case it will be required to render all UI including UI which is normally common to all Typed UI. This MAY BE DEPRECATED if a better implementation is devised. """) class IBinding(Interface): """A Binding corresponds (very) roughly to a