<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:browser="http://namespaces.zope.org/browser">

  <!-- Form Macros -->

  <browser:page
      for="*"
      name="form_macros"
      permission="zope.Public"
      class=".macros.FormMacros"
      allowed_interface="zope.interface.common.mapping.IItemMapping"
      />

  <browser:page
      for="*"
      name="widget_macros"
      permission="zope.Public"
      template="widget_macros.pt"
      />

  <browser:page
      for="*"
      name="addform_macros"
      permission="zope.Public"
      template="add.pt"
      />

  <!-- Views for Widget Errors -->

  <adapter
      for="zope.app.form.interfaces.IWidgetInputError
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.IWidgetInputErrorView"
      factory="zope.app.form.browser.exception.WidgetInputErrorView"
      permission="zope.Public"
      />

  <!-- Core display widgets -->

  <adapter
      for="zope.schema.interfaces.IField
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".DisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IBool
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".boolwidgets.BooleanDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IBytes
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".textwidgets.BytesDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IBytesLine
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".DisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IASCII
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".textwidgets.ASCIIDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IASCIILine
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".DisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IURI
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".textwidgets.URIDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IDate
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".DateDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IDatetime
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".DatetimeDisplayWidget"
      permission="zope.Public"
      />

  <!-- Core edit widgets -->

   <adapter
       for="zope.schema.interfaces.ITextLine
            zope.publisher.interfaces.browser.IBrowserRequest"
       provides="zope.app.form.browser.interfaces.ITextBrowserWidget"
       factory=".TextWidget"
       permission="zope.Public"
       />

  <adapter
      for="zope.schema.interfaces.IText
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".TextAreaWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.ISourceText
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".TextAreaWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IBytesLine
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".BytesWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IBytes
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".FileWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IASCII
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".ASCIIAreaWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IASCIILine
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".ASCIIWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IInt
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".IntWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IInt
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".UnicodeDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IFloat
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".FloatWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IFloat
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".UnicodeDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IDecimal
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".DecimalWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IDecimal
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".UnicodeDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IDatetime
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".DatetimeWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IDate
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".DateWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IBool
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".CheckBoxWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IPassword
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".PasswordWidget"
      permission="zope.Public"
      />

  <!-- Items-related widgets; they are proxies for the multiviews below. -->

  <!-- Choices (dispatch to field + vocabulary lookup) -->
  <adapter
      for="zope.schema.interfaces.IChoice
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".ChoiceDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IChoice
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".ChoiceInputWidget"
      permission="zope.Public"
      />

  <!-- Generic collections (dispatch to field + value_type lookup) -->
  <adapter
      for="zope.schema.interfaces.ICollection
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".CollectionDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.ICollection
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".CollectionInputWidget"
      permission="zope.Public"
      />

  <!-- 

       Need to repeat the above for Sequence to avoid being overridden by a
       DAV widget.  This suggests that we should be getting something
       more specific than IInputWidget.

       -->
  <adapter
      for="zope.schema.interfaces.ISequence
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".CollectionDisplayWidget"
      permission="zope.Public"
      />
  <adapter
      for="zope.schema.interfaces.ISequence
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".CollectionInputWidget"
      permission="zope.Public"
      />



  <!-- non-choice collection fields should register for the field + value type
       so as to allow specific field + value_type widgets such as the Choice
       pattern -->
  <adapter
      for="zope.schema.interfaces.ITuple
           zope.schema.interfaces.IField
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".TupleSequenceWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IList
           zope.schema.interfaces.IField
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".ListSequenceWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.ISequence
           zope.schema.interfaces.IField
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".SequenceDisplayWidget"
      permission="zope.Public"
      />

  <!-- Choice collections.  dispatch to field + vocabulary lookup.
       We must register the collection + choice factories for all ICollection
       subclasses because the field (the collection) has precedence: therefore
       a registration for (IList plus IField) would trump a registration for
       (ICollection plus IChoice), making choice lists not look up properly.
       So all new collection types should always register for IChoice if
       they want to follow in this configuration pattern. -->
  <!-- List + Choice -->
  <adapter
      for="zope.schema.interfaces.IList
           zope.schema.interfaces.IChoice
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".ChoiceCollectionDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IList
           zope.schema.interfaces.IChoice
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".ChoiceCollectionInputWidget"
      permission="zope.Public"
      />

  <!-- Tuple + Choice -->
  <adapter
      for="zope.schema.interfaces.ITuple
           zope.schema.interfaces.IChoice
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".ChoiceCollectionDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.ITuple
           zope.schema.interfaces.IChoice
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".ChoiceCollectionInputWidget"
      permission="zope.Public"
      />

  <!-- Set + Choice -->
  <adapter
      for="zope.schema.interfaces.ISet
           zope.schema.interfaces.IChoice
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".ChoiceCollectionDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.ISet
           zope.schema.interfaces.IChoice
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".ChoiceCollectionInputWidget"
      permission="zope.Public"
      />
  
  <!-- FrozenSet + Choice -->
  <adapter
      for="zope.schema.interfaces.IFrozenSet
           zope.schema.interfaces.IChoice
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".ChoiceCollectionDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IFrozenSet
           zope.schema.interfaces.IChoice
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".ChoiceCollectionInputWidget"
      permission="zope.Public"
      />

  <!-- Default Multi-Views for fields and vocabularies -->

  <adapter
      for="zope.schema.interfaces.IChoice
           zope.schema.interfaces.IBaseVocabulary
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".ItemDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IChoice
           zope.schema.interfaces.IVocabularyTokenized
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".DropdownWidget"
      permission="zope.Public"
      />

  <!-- Default Multi-Views for fields and iterable sources -->

  <adapter
      for="zope.schema.interfaces.ISet
           zope.schema.interfaces.IIterableSource
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".source.SourceMultiSelectSetWidget"
      permission="zope.Public"
      />
  
  <adapter
      for="zope.schema.interfaces.IFrozenSet
           zope.schema.interfaces.IIterableSource
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".source.SourceMultiSelectFrozenSetWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IChoice
           zope.schema.interfaces.IIterableSource
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".source.SourceDropdownWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IList
           zope.schema.interfaces.IIterableSource
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".source.SourceOrderedMultiSelectWidget"
      permission="zope.Public"
      />

  <!-- These widgets are minimal and only support lists with unique members,
       without ordering capabilities -->

  <adapter
      for="zope.schema.interfaces.ISet
           zope.schema.interfaces.IVocabularyTokenized
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".MultiSelectSetWidget"
      permission="zope.Public"
      />
      
  <adapter
      for="zope.schema.interfaces.IFrozenSet
           zope.schema.interfaces.IVocabularyTokenized
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".MultiSelectFrozenSetWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.ISet
           zope.schema.interfaces.IBaseVocabulary
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".SetDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IFrozenSet
           zope.schema.interfaces.IBaseVocabulary
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".SetDisplayWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IList
           zope.schema.interfaces.IVocabularyTokenized
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".OrderedMultiSelectWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.IList
           zope.schema.interfaces.IBaseVocabulary
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".SetDisplayWidget"
      permission="zope.Public"
      />

  <!-- Source Views -->
  <adapter
      for="zope.schema.interfaces.IChoice
           zope.schema.interfaces.ISource
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".source.SourceDisplayWidget"
      permission="zope.Public"
      />
  <adapter
      for="zope.schema.interfaces.IChoice
           zope.schema.interfaces.ISource
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".source.SourceInputWidget"
      permission="zope.Public"
      />

  <adapter
      for="zope.schema.interfaces.ISequence
           zope.schema.interfaces.ISource
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".source.SourceSequenceDisplayWidget"
      permission="zope.Public"
      />
  
    <adapter
      for="zope.schema.interfaces.IAbstractSet
           zope.schema.interfaces.ISource
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.interfaces.IDisplayWidget"
      factory=".source.SourceSequenceDisplayWidget"
      permission="zope.Public"
      />



  <!-- TODO We need a widget for tuples (and sets, for that matter). -->
  <adapter
      for="zope.schema.interfaces.IList
           zope.schema.interfaces.ISource
           zope.publisher.interfaces.browser.IBrowserRequest"
      provides="zope.app.form.browser.interfaces.ISimpleInputWidget"
      factory=".source.SourceListInputWidget"
      permission="zope.Public"
      />

  <!-- Register the form documentation with the apidoc tool -->
  <configure
      xmlns:apidoc="http://namespaces.zope.org/apidoc"
      xmlns:zcml="http://namespaces.zope.org/zcml"
      zcml:condition="have apidoc">

    <apidoc:bookchapter
        id="form"
        title="Widgets and Forms"
        />
    <apidoc:bookchapter
        id="bwidget"
        title="Basic Widgets"
        doc_path="README.txt"
        parent="form"
        />
    <apidoc:bookchapter
        id="swidget"
        title="Source Widgets"
        doc_path="source.txt"
        parent="form"
        />
    <apidoc:bookchapter
        id="awidget"
        title="Advanced Widgets"
        doc_path="widgets.txt"
        parent="form"
        />
    <apidoc:bookchapter
        id="formdirective"
        title="The browser:form Directive"
        doc_path="form.txt"
        parent="form"
        />
  </configure>

</configure>
