<!DOCTYPE Article PUBLIC "-//Davenport//DTD DocBook V3.0//EN">

<Article id="modsnake-api">
<ArtHeader>
<Title>Mod Snake API</Title>
<Author>
  <FirstName>Jon</FirstName>
  <Surname>Travis</Surname>
  <Affiliation>
    <address><email>jtravis@p00p.org</email></address>
  </Affiliation>    
</Author>
<PubDate>v0.50, 09 October 2000</PubDate>
</ArtHeader>

<Sect1 id="terminology"><Title>Terminology</Title>
  <Para>
    The following important terms are used throughout this documentation:
  </Para>
  <variablelist>
    <varlistentry><term id="term-callback">Callback</term>
      <listitem><para>
        A <literal>Callable</literal> Python object.  This object can take the
        form of an object method, a function, etc.
      </para></listitem>
    </varlistentry>

    <varlistentry><term>Directive</term>
      <listitem><para>
        A line in an Apache configuration file 
        (<filename>httpd.conf</filename>, <filename>.htaccess</filename>, etc.)
      </para></listitem>
    </varlistentry>

    <varlistentry><term>PyMod</term>
      <listitem><para>
        A PyMod is a grouping of function callbacks, callback data, and 
        directive information.  In general, this cooresponds to a class within 
        a Python module.
      </para></listitem>
    </varlistentry>
  </variablelist>

</Sect1>

<Sect1 id="modsnakepymod-api"><Title>ModSnakePyMod API</Title>
  <Para>
    The ModSnakePyMod API is a specialized API available to callbacks within
    PyMods, called from mod_snake. Occasionally a ModSnakePyMod
    object will be passed into a PyMod's callback function.  This object has 
    special attributes and methods for dictating how a PyMod will 
    interact with the Apache server.
  </Para>

  <Sect2><Title>add_hook</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    
    <Para><Command>ModSnakePyMod.add_hook</Command>(
      <Parameter>hookname</Parameter>,
      <Parameter>hookfunc</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Validity</bridgehead>
    <Para>
      Valid within the <function>__init__</function> method of the PyMod's 
      object class.
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>hookname</Parameter>
        - (type String) a hook name from the hook table in 
          <xref linkend="table-hooks">
      </Para></ListItem>
      <ListItem><Para>
        <Parameter>hookfunc</Parameter>
        - (type Callable) a function to call when the given hookname phase is
        reached by the server.
        </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine registers hooks that Apache can call at designated time.
      A ModSnakePyMod is passed into the <Function>__init__</Function> method 
      via mod_snake. The
      <Parameter>hookname</Parameter> can be a variety of strings, each 
      cooresponding to a different
      hook phase within Apache. The <Parameter>hookfunc</Parameter> is the
      callback function to
      call whenever the phase cooresponding to <Parameter>hookname</Parameter>
      is reached. In the
      subsequent sections, when referring to any specific hook (i.e.
      'create_dir_config') the reference is to the actual function (hookfunc)
      associated with it by the PyMod.
    </Para>

    <Para>
      <Table id="table-hooks"><Title>Mod Snake/Apache Hooks</Title>
        <TGroup cols="2">
        <colspec colname="hookname">
        <colspec colname="apacheequiv">
        <THead>
          <row><entry>Hook Name</Entry><Entry>Apache Equivalent</Entry></row>
        </THead>
        <TBody> 
          <row>
            <entry><link linkend="create-dir-config">create_dir_config</link>
            </entry>
            <entry>The per-dir creation function within the module record
            </entry>
          </row>
          <row>
            <entry><link linkend="merge-dir-config">merge_dir_config</link>
            </entry>
            <entry>The per-dir merge function within the module record
            </entry>
          </row>

          <row>
            <entry><link linkend="create-svr-config">create_svr_config</link>
            </entry>
            <entry>The per-server creation function within the module record
            </entry>
          </row>
          <row>
            <entry><link linkend="merge-svr-config">merge_svr_config</link>
            </entry>
            <entry>The per-server merge function within the module record
            </entry>
          </row>
          <row>
            <entry><link linkend="post-config">post_config</link>
            </entry>
            <entry>ap_hook_post_config</entry>
          </row>
          <row>
            <entry><link linkend="open-logs">open_logs</link>
            </entry>
            <entry>ap_hook_open_logs</entry>
          </row>
          <row>
            <entry><link linkend="pre-connection">pre_connection</link>
            </entry>
            <entry>ap_hook_pre_connection</entry>
          </row>
          <row>
            <entry><link linkend="process-connection">process_connection</link>
            </entry>
            <entry>ap_hook_process_connection</entry>
          </row>
          <row>
            <entry><link linkend="post-read-request">post_read_request</link>
            </entry>
            <entry>ap_hook_post_read_request</entry>
          </row>
          <row>
            <entry><link linkend="translate-name">translate_name</link>
            </entry>
            <entry>ap_hook_translate_name</entry>
          </row>
          <row>
            <entry><link linkend="header-parser">header_parser</link>
            </entry>
            <entry>ap_hook_header_parser</entry>
          </row>
          <row>
            <entry><link linkend="access-checker">access_checker</link>
            </entry>
            <entry>ap_hook_access_checker</entry>
          </row>
          <row>
            <entry><link linkend="check-user-id">check_user_id</link>
            </entry>
            <entry>ap_hook_check_user_id</entry>
          </row>
          <row>
            <entry><link linkend="auth-checker">auth_checker</link>
            </entry>
            <entry>ap_hook_auth_checker</entry>
          </row>
          <row>
            <entry><link linkend="fixups">fixups</link>
            </entry>
            <entry>ap_hook_fixups</entry>
          </row>
          <row>
            <entry><link linkend="content-handler">content-handler</link>
            </entry>
            <entry>The handler_rec structure within the module
            </entry>
          </row>
          <row>
            <entry><link linkend="log-transaction">log_transaction</link>
            </entry>
            <entry>ap_hook_log_transaction</entry>
          </row>
          <row>
            <entry><link linkend="insert-filter">insert_filter</link>
            </entry>
            <entry>ap_hook_insert_filter</entry>
          </row>
        </TBody>
        </TGroup>
      </Table>
    </Para>  

    <Sect3 id="create-dir-config"><Title>create_dir_config</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
        <Para><Command>create_dir_config</Command>(
        <Parameter>path</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>path</Parameter>
            - (type String or <literal>None</literal>) A path given to the 
            PyMod, designating the association between the callback's return 
            data and the path.  This pertains to the directory that the 
            directory config is being created for. For instance, when a 
            <Filename>.htaccess</Filename> in a particular directory is read.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The PyMod may return any data it wishes from this callback. mod_snake
        will pass the return value from this method to a variety of other
        callbacks, registered by the PyMod.
      </Para>

      <bridgehead renderas=sect3>Description</bridgehead>
      <Para>
        Apache will call the create_dir_config callback in the PyMod whenever
        it is required to generate per-directory configuration data.
        <Parameter>path</Parameter> may be <literal>None</literal>, indicating
        that the path associated with this call is in a server context, and 
        not necessarily associated with any given directory. 
      </Para>
    </Sect3>

    <Sect3 id="merge-dir-config"><Title>merge_dir_config</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
        <Para><Command>merge_dir_config</Command>(
        <Parameter>per_dir1</Parameter>,
        <Parameter>per_dir2</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>per_dir1</Parameter>
          - The base per-directory PyMod data 
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>per_dir2</Parameter>
          - The sub-directory per-directory PyMod data
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The PyMod may return any data it wishes from this callback. If this
        callback is not performed, it is the same as though this callback
        returned <Parameter>per_dir2</Parameter>. mod_snake will pass the 
        return value from this function to a variety of other callbacks, 
        registered by the PyMod.
      </Para>

      <bridgehead renderas=sect3>Description</bridgehead>
      <Para>
        Apache occasionally gives modules the chance to combine per-directory
        configuration information into 1 per-dir configuration. Apache gives
        the base and new directory configuration information back to the 
        module, and the module must combine them in whatever fashion it sees 
        fit. This can be especially useful for doing fine grained configuration
        throughout sub-directories.
      </Para>
    </Sect3>

    <Sect3 id="create-svr-config"><Title>create_svr_config</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>create_svr_config</Command>(
        <Parameter>svr</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>svr</Parameter>
          - The server for which the configuration is being created for
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The PyMod may return any data it wishes from this callback. mod_snake
        will pass the return value from this function to a variety of other
        callbacks, registered by the Python module.
       </Para>

      <bridgehead renderas=sect3>Description</bridgehead>
      <Para>
        Apache will call the create_svr_config callback in the module whenever
        the module is required to generate per-server configuration data. 
      </Para>
    </Sect3>

    <Sect3 id="merge-svr-config"><Title>merge_svr_config</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>merge_svr_config</Command>(
        <Parameter>per_svr1</Parameter>,
        <Parameter>per_svr2</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>per_svr1</Parameter>
          - The base per-server module data 
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>per_svr2</Parameter>
          - The new per-server module data
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The PyMod may return any data it wishes from this callback. If this
        callback is not performed, it is the same as though this callback
        returned <Parameter>per_svr2</Parameter>. mod_snake will pass the 
        return value from this
        function to a variety of other callbacks, registered by the Python
        module.
      </Para>

      <bridgehead renderas=sect3>Description</bridgehead>
      <Para>
        Apache occasionally gives modules the chance to combine per-server
        configuration information into 1 per-server configuration. Apache
        gives the base and new server configuration information back to the
        module, and the module must combine them in whatever fashion it sees
        fit.
      </Para>
    </Sect3>

    <Sect3 id="post-config"><Title>post_config</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>post_config</Command>(
        <Parameter>svr_cfg</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of post_config is not checked, nor used.
      </Para>

      <bridgehead renderas=sect3>Description</bridgehead>
      <Para>
        This callback is called after Apache has read the configuration file.
        Keep in mind that Apache does read the configuration file more than
        one time.
      </Para>
    </Sect3>

    <Sect3 id="open-logs"><Title>open_logs</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>open_logs</Command>(
        <Parameter>svr_cfg</Parameter>,
        <Parameter>module</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>module</Parameter>
          - (type ModSnakePyMod) a reference to the module's
          external representation. This can be used to obtain the current
          server record, etc.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of open_logs is not checked, nor used.
      </Para>

      <bridgehead renderas=sect3>Description</bridgehead>
      <Para>
        The open_logs callback will be called when Apache has finished reading
        the configuration and allows modules to open up logs. Module writers
        may want to register this hook if they intend to write their own 
        logging routines (instead of using built in mod_snake API calls), as 
        it gives them 'special' permission to open logfiles prior to becoming 
        an ordinary (no-permissions) process. mod_snake passes in a 
        ModSnakePyMod module descriptor, which the module can use at its 
        discretion.
      </Para>
    </Sect3>


    <Sect3 id="pre-connection"><Title>pre_connection</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>pre_connection</Command>(
        <Parameter>svr_cfg</Parameter>,
        <Parameter>conn_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>conn_rec</Parameter>
          - (type conn_rec) Information about the current connection.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of pre_connection is not checked, nor used.
      </Para>

      <bridgehead renderas=sect3>Compatability</bridgehead>
      <Para>
        This hook is only available when mod_snake is running on an Apache
        2.0 server.
      </Para>

      <bridgehead renderas=sect3>Description</bridgehead>
      <Para>
        The pre_connection callback is called when Apache receives an incoming
        connection on a socket. All pre_connection callbacks are run until
        one returns a value other than <literal>OK</literal> or <literal>DECLINED</literal>.
      </Para>
    </Sect3>


    <Sect3 id="process-connection"><Title>process_connection</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>process_connection</Command>(
        <Parameter>svr_cfg</Parameter>,
        <Parameter>conn_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>conn_rec</Parameter>
          - (type conn_rec) Information about the current connection.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of process_connection is used to determine whether further
        action must be performed. If the return value is <literal>OK</literal>, the connection
        is dropped.
      </Para>

      <bridgehead renderas=sect3>Compatability</bridgehead>
      <Para>
        This hook is only available when mod_snake is running on an Apache
        2.0 server.
      </Para>

      <bridgehead renderas=sect3>Description</bridgehead>
      <Para>
        The process_connection callback is made directly after the 
        pre_connection callback. All process_connection callbacks are run 
        until one returns a value other than <literal>DECLINED</literal>.
      </Para>
    </Sect3>


    <Sect3 id="post-read-request"><Title>post_read_request</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>post_read_request</Command>(
        <Parameter>dir_cfg</Parameter>,
        <Parameter>svr_cfg</Parameter>,
        <Parameter>request_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>dir_cfg</Parameter>
          - Directory configuration, as returned by calls to the 
          create_dir_config and merge_dir_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>request_rec</Parameter>
          - (type request_rec) Information about the incoming request.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of post_read_request is one of the standard Apache hook
        result codes.
      </Para>

      <bridgehead renderas=sect3>Descriptions</bridgehead>
      <Para>
        The post_read_request callback is executed directly after the request
        has been made and before any URI translation is performed. All 
        post_read_request callbacks are executed in all modules until one 
        returns a value other than <literal>OK</literal> or <literal>DECLINED</literal>.
      </Para>
    </Sect3>


    <Sect3 id="translate-name"><Title>translate_name</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>translate_name</Command>(
        <Parameter>dir_cfg</Parameter>,
        <Parameter>svr_cfg</Parameter>,
        <Parameter>request_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>dir_cfg</Parameter>
          - Directory configuration, as returned by calls to the 
          create_dir_config and merge_dir_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>request_rec</Parameter>
          - (type request_rec) Information about the incoming request.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of translate_name is one of the standard Apache hook result
        codes.
      </Para>

      <bridgehead renderas=sect3>Descriptions</bridgehead>
      <Para>
        The translate_name callback is executed after the post_read_request
        callback is performed, and before the header_parsing callback is 
        executed. During this phase a module may perform translations on the 
        requested URI. All translate_name callbacks are executed in all 
        modules until one returns a value other than <literal>DECLINED</literal>.
      </Para>
    </Sect3>

    <Sect3 id="header-parser"><Title>header_parser</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>header_parser</Command>(
        <Parameter>dir_cfg</Parameter>,
        <Parameter>svr_cfg</Parameter>,
        <Parameter>request_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>dir_cfg</Parameter>
          - Directory configuration, as returned by calls to the 
          create_dir_config and merge_dir_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>request_rec</Parameter>
          - (type request_rec) Information about the incoming request.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of header_parser is one of the standard Apache hook result
        codes.
      </Para>

      <bridgehead renderas=sect3>Descriptions</bridgehead>
      <Para>
        The header_parser callback is made when Apache wants to give a chance
        to the module to validate or deny a given request. The module can
        inspect the values of request_rec.method to determine an appropriate
        course of action. All header_parser callbacks are executed in all
        modules until one returns a value other than <literal>OK</literal> or <literal>DECLINED</literal>.
      </Para>
    </Sect3>


    <Sect3 id="access-checker"><Title>access_checker</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>access_checker</Command>(
        <Parameter>dir_cfg</Parameter>,
        <Parameter>svr_cfg</Parameter>,
        <Parameter>request_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>dir_cfg</Parameter>
          - Directory configuration, as returned by calls to the 
          create_dir_config and merge_dir_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>request_rec</Parameter>
          - (type request_rec) Information about the incoming request.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of access_checker is one of the standard Apache hook result
        codes.
      </Para>

      <bridgehead renderas=sect3>Descriptions</bridgehead>
      <Para>
        The access_checker callback is called after the header_parser stage,
        and gives the module an opportunity to allow or deny a request based
        upon whichever criteria it wishes. mod_access uses the access_checker
        hook in order to allow or deny requests based upon various criteria
        such as IP address.
      </Para>
    </Sect3>

    <Sect3 id="check-user-id"><Title>check_user_id</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>check_user_id</Command>(
        <Parameter>dir_cfg</Parameter>,
        <Parameter>svr_cfg</Parameter>,
        <Parameter>request_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>dir_cfg</Parameter>
          - Directory configuration, as returned by calls to the 
          create_dir_config and merge_dir_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>request_rec</Parameter>
          - (type request_rec) Information about the incoming request.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of check_user_id is one of the standard Apache hook result
        codes.
      </Para>

      <bridgehead renderas=sect3>Descriptions</bridgehead>
      <Para>
        The check_user_id callback allows modules to perform user 
        authentication before allowing them to proceed. This can be done in a 
        variety of ways, such as a database, configuration directive, or 
        anything the module wishes. This routine should typically return one 
        of 3 values, HTTP_UNAUTHORIZED, <literal>OK</literal>, and <literal>DECLINED</literal>, but need not be 
        limited by these.  All check_user_id handlers are run until one 
        returns a value other than <literal>DECLINED</literal>.
      </Para>
    </Sect3>


    <Sect3 id="auth-checker"><Title>auth_checker</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>auth_checker</Command>(
        <Parameter>dir_cfg</Parameter>,
        <Parameter>svr_cfg</Parameter>,
        <Parameter>request_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>dir_cfg</Parameter>
          - Directory configuration, as returned by calls to the 
          create_dir_config and merge_dir_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>request_rec</Parameter>
          - (type request_rec) Information about the incoming request.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of auth_checker is one of the standard Apache hook result
        codes.
      </Para>

      <bridgehead renderas=sect3>Descriptions</bridgehead>
      <Para>
        The auth_checker callback allows modules to grant or deny access to
        data based upon their user data. All auth_checker handlers are run
        until one returns a value other than <literal>DECLINED</literal>.
      </Para>
    </Sect3>


    <Sect3 id="type-checker"><Title>type_checker</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>type_checker</Command>(
        <Parameter>dir_cfg</Parameter>,
        <Parameter>svr_cfg</Parameter>,
        <Parameter>request_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>dir_cfg</Parameter>
          - Directory configuration, as returned by calls to the 
          create_dir_config and merge_dir_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>request_rec</Parameter>
          - (type request_rec) Information about the incoming request.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of type_checker is one of the standard Apache hook result
        codes.
      </Para>

      <bridgehead renderas=sect3>Descriptions</bridgehead>
      <Para>
        The type_checker callback is used to determine a MIME type for the
        requested document. The module can use this callback and use whatever
        server configuration it desires to associate a type with the requested
        document. This type is later used to determine which handler will
        be called for the type. All type_checker handlers are run until one
        returns a value other than <literal>DECLINED</literal>.
      </Para>
    </Sect3>


    <Sect3 id="fixups"><Title>fixups</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>fixups</Command>(
        <Parameter>dir_cfg</Parameter>,
        <Parameter>svr_cfg</Parameter>,
        <Parameter>request_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>dir_cfg</Parameter>
          - Directory configuration, as returned by calls to the 
          create_dir_config and merge_dir_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>request_rec</Parameter>
          - (type request_rec) Information about the incoming request.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of fixups is one of the standard Apache hook result codes.
      </Para>

      <bridgehead renderas=sect3>Descriptions</bridgehead>
      <Para>
        The fixups callback is used as a last ditch effort by modules to tweak
        any headers, etc. before the request is handed off to the 
        content-handler.  mod_env uses this stage to add various environment 
        variables before passing along the request. All fixups handlers are 
        run until one returns something ore than <literal>OK</literal> or <literal>DECLINED</literal>.
      </Para>
    </Sect3>

    <Sect3 id="content-handler"><Title>content_handler</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>content_handler</Command>(
        <Parameter>dir_cfg</Parameter>,
        <Parameter>svr_cfg</Parameter>,
        <Parameter>request_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>dir_cfg</Parameter>
          - Directory configuration, as returned by calls to the 
          create_dir_config and merge_dir_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>request_rec</Parameter>
          - (type request_rec) Information about the incoming request.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of content_handler is one of the standard Apache hook result
        codes.
      </Para>

      <bridgehead renderas=sect3>Descriptions</bridgehead>
      <Para>
        The content_handler is used to actually generate content to be returned
        to the client. This can range in anything from reading files on the
        system, to querying database entries, to formulating data from the
        system environment. The content_handler phase in mod_snake is slightly
        different than that in regular Apache, in that if a module registers
        with the content_handler phase, all requsets for any content will
        be passed into this routine. If the module does not wish to handle
        the request for a specific content type, it can return <literal>DECLINED</literal>. All
        content_handler handlers are run until one returns something other
        than <literal>DECLINED</literal>.
      </Para>
    </Sect3>

    <Sect3 id="log-transaction"><Title>log_transaction</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
      
        <Para><Command>log_transaction</Command>(
        <Parameter>dir_cfg</Parameter>,
        <Parameter>svr_cfg</Parameter>,
        <Parameter>request_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>dir_cfg</Parameter>
          - Directory configuration, as returned by calls to the 
          create_dir_config and merge_dir_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>request_rec</Parameter>
          - (type request_rec) Information about the incoming request.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of log_transaction is one of the standard Apache hook result
        codes.
      </Para>

      <bridgehead renderas=sect3>Descriptions</bridgehead>
      <Para>
        The log_transaction handler enables modules to do any specialized 
        logging after the request has been processed, and the content been 
        sent to the client. All log_transaction handlers are run until one 
        returns a value other than <literal>OK</literal> or 
        <literal>DECLINED</literal>.
      </Para>
    </Sect3>


    <Sect3 id="insert-filter"><Title>insert_filter</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
        <Para><Command>insert_filter</Command>(
        <Parameter>dir_cfg</Parameter>,
        <Parameter>svr_cfg</Parameter>,
        <Parameter>request_rec</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>dir_cfg</Parameter>
          - Directory configuration, as returned by calls to the 
          create_dir_config and merge_dir_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>request_rec</Parameter>
          - (type request_rec) Information about the incoming request.
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The result of insert_filter is one of the standard Apache hook result
        codes.
      </Para>

      <bridgehead renderas=sect3>Compatability</bridgehead>
      <Para>
        This hook is only available when mod_snake is running on an Apache
        2.0 server.
      </Para>

      <bridgehead renderas=sect3>Descriptions</bridgehead>
      <Para>
        The insert_filter hook is called directly after the fixups callback.
        Within this hook, the PyMod can add a filter to the filter chain 
        (See <xref linkend="add-output-filter">).  All insert_filter hooks 
        are run, regardless of return value.
      </Para>
    </Sect3>


    <Sect3 id="standard-hook-returns">
      <Title>Standard Hook Return Values</Title>
      <Para>
        Hooks may return any integer value that they wish, but there are 
        already a myriad of established return values and associated meanings.
        The values used internally within Apache (and thus available to modules
        through the mod_snake API, such as mod_snake.HTTP_UNAUTHORIZED) 
        include:
      </Para>

      <Table id="table-standard-hook-returns">
        <Title>Standard Hook Return Values</Title>
        <TGroup cols="1">
        <colspec colname="return-value">
        <TBody> 
          <row><entry>DONE</entry></row>
          <row><entry>DECLINED</entry></row>
          <row><entry>OK</entry></row>
          <row><entry>HTTP_CONTINUE</entry></row>
          <row><entry>HTTP_SWITCHING_PROTOCOLS</entry></row>
          <row><entry>HTTP_OK</entry></row>
          <row><entry>HTTP_CREATED</entry></row>
          <row><entry>HTTP_ACCEPTED</entry></row>
          <row><entry>HTTP_NON_AUTHORITATIVE</entry></row>
          <row><entry>HTTP_NO_CONTENT</entry></row>
          <row><entry>HTTP_RESET_CONTENT</entry></row>
          <row><entry>HTTP_PARTIAL_CONTENT</entry></row>
          <row><entry>HTTP_MULTI_STATUS</entry></row>
          <row><entry>HTTP_MULTIPLE_CHOICES</entry></row>
          <row><entry>HTTP_MOVED_PERMANENTLY</entry></row>
          <row><entry>HTTP_MOVED_TEMPORARILY</entry></row>
          <row><entry>HTTP_SEE_OTHER</entry></row>
          <row><entry>HTTP_NOT_MODIFIED</entry></row>
          <row><entry>HTTP_USE_PROXY</entry></row>
          <row><entry>HTTP_TEMPORARY_REDIRECT</entry></row>
          <row><entry>HTTP_BAD_REQUEST</entry></row>
          <row><entry>HTTP_UNAUTHORIZED</entry></row>
          <row><entry>HTTP_PAYMENT_REQUIRED</entry></row>
          <row><entry>HTTP_FORBIDDEN</entry></row>
          <row><entry>HTTP_NOT_FOUND</entry></row>
          <row><entry>HTTP_METHOD_NOT_ALLOWED</entry></row>
          <row><entry>HTTP_NOT_ACCEPTABLE</entry></row>
          <row><entry>HTTP_PROXY_AUTHENTICATION_REQUIRED</entry></row>
          <row><entry>HTTP_REQUEST_TIME_OUT</entry></row>
          <row><entry>HTTP_CONFLICT</entry></row>
          <row><entry>HTTP_DONE</entry></row>
          <row><entry>HTTP_LENGTH_REQUIRED</entry></row>
          <row><entry>HTTP_PRECONDITION_FAILED</entry></row>
          <row><entry>HTTP_REQUEST_ENTITY_TOO_LARGE</entry></row>
          <row><entry>HTTP_REQUEST_URI_TOO_LARGE</entry></row>
          <row><entry>HTTP_UNSUPPORTED_MEDIA_TYPE</entry></row>
          <row><entry>HTTP_RANGE_NOT_SATISFIABLE</entry></row>
          <row><entry>HTTP_EXPECTATION_FAILED</entry></row>
          <row><entry>HTTP_UNPROCESSABLE_ENTITY</entry></row>
          <row><entry>HTTP_LOCKED</entry></row>
          <row><entry>HTTP_FAILED_DEPENDENCY</entry></row>
          <row><entry>HTTP_INTERNAL_SERVER_ERROR</entry></row>
          <row><entry>HTTP_NOT_IMPLEMENTED</entry></row>
          <row><entry>HTTP_BAD_GATEWAY</entry></row>
          <row><entry>HTTP_SERVICE_UNAVAILABLE</entry></row>
          <row><entry>HTTP_GATEWAY_TIME_OUT</entry></row>
          <row><entry>HTTP_VERSION_NOT_SUPPORTED</entry></row>
          <row><entry>HTTP_VARIANT_ALSO_VARIES</entry></row>
          <row><entry>HTTP_INSUFFICIENT_STORAGE</entry></row>
          <row><entry>HTTP_NOT_EXTENDED</entry></row>
        </TBody>
        </TGroup>
      </Table>
      <Para>
        Note that DONE has the special meaning that the module has served the
        response completely, and no other hooks should be called, <literal>OK</literal> has the
        special meaning that the handler has handled a given phase, and 
        <literal>DECLINED</literal> means that the handler did not process the stage, and that 
        Apache should continue to look for a handler to process it.
      </Para>
    </Sect3>
  </Sect2>

  <Sect2><Title>add_directives</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    
      <Para><Command>ModSnakePyMod.add_directives</Command>(
      <Parameter>directive_dict</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Validity</bridgehead>
    <Para>
      Valid within the __init__ method of the module's object class.
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>directive_dict</Parameter>
          - A dictionary specifying the name, location, type,
          and callbacks for Python created configuration directives. The 
          dictionary has the form: 
<Screen width="61">
{ ``DirectiveName'' : (directive_location, functype, func_ptr), ... }
</Screen>
      </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      Python written modules running under mod_snake have the same ability
      as C written modules when it comes to creating custom configuration
      directives. The directive_dict contains a dictionary of directive
      names, and associated attributes.
    </Para>

    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>DirectiveName</Parameter>
        - specifies the textual name within the Apache configuration
        file to trigger the modules directive handler (func_ptr). This value
        is case insensitive.
      </Para></ListItem>
      <ListItem><Para>
        <Parameter>directive_location</Parameter>
        - Puts a limit on the locations where this directive
        is valid. The supported values may also be binary ORed togther to
        combine multiple types of locations. The current possible values
        are:
        <ItemizedList>
        <ListItem><Para>
          <Parameter>mod_snake.OR_LIMIT</Parameter>
          - The directive is valid in the main configuration
          file inside &lt;directory&gt; and &lt;Location&gt; blocks, and also within
          .htaccess files when AllowOverride Limit is set.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>mod_snake.OR_OPTIONS</Parameter>
          - The directive is valid anywhere in the main
          configuration file, and also within .htaccess files when 
          AllowOverride Options is set.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>mod_snake.OR_FILEINFO</Parameter>
          - The directive is valid anywhere in the
          main configuration file, and also within .htaccess files when
          AllowOverride FileInfo is set.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>mod_snake.OR_AUTHCFG</Parameter>
          - The directive is valid in the main configuration
          file inside &lt;directory&gt; and &lt;Location&gt; blocks, and also within
          .htaccess files when AllowOverride AuthConfig is set.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>mod_snake.OR_INDEXES</Parameter>
          - The directive is valid anywhere in the main
          configuration file, and also within .htaccess files when 
          AllowOverride Indexes is set.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>mod_snake.ACCESS_CONF</Parameter>
          - The directive is valid in the main configuration
          file within &lt;directory&gt; and &lt;Location&gt; blocks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>mod_snake.RSRC_CONF</Parameter>
          - The directive is valid in the main configuration
          file, outside of &lt;directory&gt; and &lt;Location&gt; blocks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>mod_snake.OR_ALL</Parameter>
          - The directive is valid anywhere.
        </Para></ListItem>
        </ItemizedList>
      </Para></ListItem>
      <ListItem><Para>
        <Parameter>functype</Parameter>
        - Designates the format that the arguments to the directive
        callback function take. This alleviates some of the hassle of having
        each module parse all of their directives manually. Note that the
        callback functions associated with the functype can potentially
        have many different declarations (especially when doing 1 or etc.). 
        <ItemizedList>
        <ListItem><Para>
          <Parameter>mod_snake.RAW_ARGS</Parameter>
          - The arguments to the directive are passed in, unparsed. 
          </Para><Para>
            <Command>func</Command>(
            <Parameter>self</Parameter>,
            <Parameter>dir_data</Parameter>,
            <Parameter>argline</Parameter>)
        </Para></ListItem>

        <ListItem><Para>
          <Parameter>mod_snake.TAKE1</Parameter>
          - The directive takes only one argument 
          </Para><Para>
            <Command>func</Command>(
            <Parameter>self</Parameter>,
            <Parameter>dir_data</Parameter>,
            <Parameter>arg1</Parameter>)
        </Para></ListItem>

        <ListItem><Para>
          <Parameter>mod_snake.TAKE2</Parameter>
          - The directive takes exactly two arguments
          </Para><Para>
            <Command>func</Command>(
            <Parameter>self</Parameter>,
            <Parameter>dir_data</Parameter>,
            <Parameter>arg1</Parameter>,
            <Parameter>arg2</Parameter>)
        </Para></ListItem>

        <ListItem><Para>
          <Parameter>mod_snake.ITERATE</Parameter>
          - The directive can take multiple arguments,
          but the associated callback function will be executed once for
          each argument.
          </Para><Para>
            <Command>func</Command>(
            <Parameter>self</Parameter>,
            <Parameter>dir_data</Parameter>,
            <Parameter>arg1</Parameter>)
        </Para></ListItem>

        <ListItem><Para>
          <Parameter>mod_snake.ITERATE2</Parameter>
          - The directive can take at least 2 arguments,
          but the second argument is iterated over, for > 2 arguments. 
          </Para><Para>
            <Command>func</Command>(
            <Parameter>self</Parameter>,
            <Parameter>dir_data</Parameter>,
            <Parameter>arg1</Parameter>,
            <Parameter>arg2</Parameter>)
        </Para></ListItem>

        <ListItem><Para>
          <Parameter>mod_snake.FLAG</Parameter>
          - The directive takes 1 argument, 'on' or 'off'.
          Within the module this argument is represented as true or false.
          </Para><Para>
            <Command>func</Command>(
            <Parameter>self</Parameter>,
            <Parameter>dir_data</Parameter>,
            <Parameter>on_or_off</Parameter>)
        </Para></ListItem>

        <ListItem><Para>
          <Parameter>mod_snake.NO_ARGS</Parameter>
          - The directive takes no arguments
          </Para><Para>
            <Command>func</Command>(
            <Parameter>self</Parameter>,
            <Parameter>dir_data</Parameter>)
        </Para></ListItem>

        <ListItem><Para>
          <Parameter>mod_snake.TAKE12</Parameter>
          - The directive can take either 1 or 2 arguments
          </Para><Para>
            <Command>func</Command>(
            <Parameter>self</Parameter>,
            <Parameter>dir_data</Parameter>,
            <Parameter>arg1</Parameter>,
            <Parameter>*arg2</Parameter>)
        </Para></ListItem>

        <ListItem><Para>
          <Parameter>mod_snake.TAKE3</Parameter>
          - The directive takes exactly 3 arguments
          </Para><Para>
            <Command>func</Command>(
            <Parameter>self</Parameter>,
            <Parameter>dir_data</Parameter>,
            <Parameter>arg1</Parameter>,
            <Parameter>arg2</Parameter>,
            <Parameter>arg3</Parameter>)
        </Para></ListItem>

        <ListItem><Para>
          <Parameter>mod_snake.TAKE23</Parameter>
          - The directive takes either 2 or 3 arguments
          </Para><Para>
            <Command>func</Command>(
            <Parameter>self</Parameter>,
            <Parameter>dir_data</Parameter>,
            <Parameter>arg1</Parameter>,
            <Parameter>*arg23</Parameter>)
        </Para></ListItem>

        <ListItem><Para>
          <Parameter>mod_snake.TAKE123</Parameter>
          - The directive takes either 1, 2 or 3 arguments
          </Para><Para> 
            <Command>func</Command>(
            <Parameter>self</Parameter>,
            <Parameter>dir_data</Parameter>,
            <Parameter>*arg123</Parameter>)
        </Para></ListItem>

        <ListItem><Para>
          <Parameter>mod_snake.TAKE13</Parameter>
          - The directive takes either 1 or 3 arguments
          </Para><Para> 
            <Command>func</Command>(
            <Parameter>self</Parameter>,
            <Parameter>dir_data</Parameter>,
            <Parameter>*arg1or3</Parameter>)
        </Para></ListItem>
      </ItemizedList>
      </Para></ListItem>
      <ListItem><Para>
        <Parameter>func_ptr</Parameter>
        - A pointer to a function to call when the directive is
        processed within the configuration file. The function prototype
        must match that expected by the caller (as given by the functype).
        In addition, the first argument passed to func_ptr is that of a
        per-directory data structure, as returned by the modules 
        create_dir_config callback, if it exists.
      </Para></ListItem>
      </ItemizedList>
    </Para>
  </Sect2>

  <Sect2><Title>profile_obj</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para>
      This attribute of the ModSnakePyMod object holds the value of the 
      profiling object. If profiling is not enabled, this value will be None. 
      The profiling object is an instantiation of profile.Profile class. 
    </Para>
  </Sect2>
  
  <Sect2><Title>module</Title>
    <Para>
      This attribute of the ModSnakePyMod object holds the value of the Python
      module containing the loaded pymod. For instance, if the pymod loaded
      into the server via the SnakeModule line was: SnakeModule spam.eggs,
      the module attribute will contain a reference to the spam module.
    </Para>
  </Sect2>

  <Sect2><Title>add_version_component</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>ModSnakePyMod.add_version_component</Command>(vers)
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      The HTTP header, "Server: ", returned by Apache on requests can be
      set to include additional information for modules loaded.  This
      method can be used to add module data into the server string which all
      clients see.  The string should be of the form, "module/version", such
      as "mod_snake/1.2.3".  This routine should be called in the module's
      initialization phase.
    </Para>
  </Sect2>

  <Sect2><Title>get_hooks</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>ModSnakePyMod.get_hooks</Command>()</Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      This method returns a dictionary of { hookname : funcref } pairs.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      The get_hooks method looks directly within the loaded PyMod to determine
      which hooks it has hooked into (via add_hook). The returned value
      is a dictionary containing the hook name and a reference to the function
      which gets called for that hook.
    </Para>
  </Sect2>

  <Sect2 id="register-output-filter"><Title>register_output_filter</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>ModSnakePyMod.register_output_filter</Command>(
    <Parameter>name</Parameter>,
    <Parameter>callback</Parameter>,
    <Parameter>type</Parameter>
    )</Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>name</Parameter>
        - The name of the filter.  This string is left to the PyMod's
          discretion.  It distinguishes it from other filters, and allows
          it to be added from external means, such as 
          <filename>httpd.conf</filename>
      </Para></ListItem>
      <ListItem><Para>
        <Parameter>callback</Parameter>
        - The function which should be called when it is given its turn to
        process outgoing data.
      </Para></ListItem>
      <ListItem><Para>
        <Parameter>type</Parameter>
        - One of 
        <literal>mod_snake.FTYPE_CONTENT</literal>, 
        <literal>mod_snake.FTYPE_HTTP_HEADER</literal>, 
        <literal>mod_snake.FTYPE_TRANSCODE</literal>, 
        <literal>mod_snake.FTYPE_CONNECTION</literal>, or
        <literal>mod_snake.FTYPE_NETWORK</literal> indicating when the
        filter should be run.  Content filters are for altering content.  
        Transcode is a special type of filter type for doing transport
        based encoding (chunking).  Connection based filters are filters which
        modify content, but are done on a more connection oriented basis.  
        Network are the lowest level filter possible -- they read/write data
        directly to the remote client.  The aforementioned filter types are
        sorted in execution order, with NETWORK being the first run on input
        filters, and last run on output filters.
      </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Compatability</bridgehead>
    <Para>
      This function is only available when mod_snake is running on an Apache
      2.0 server.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      By using output filters, PyMods have the ability to process data written
      by content generators before it is sent to the remote client.  This
      routine only needs to be called once in each module for each filter.  
      It provides Apache with information needed to associate the textual name
      of the filter with the callback function.
    </Para>

    <Sect3><Title>output_filter</Title>
      <bridgehead renderas=sect3>Synopsis</bridgehead>
        <Para><Command>output_filter</Command>(
        <Parameter>dir_cfg</Parameter>,
        <Parameter>svr_cfg</Parameter>,
        <Parameter>filter</Parameter>,
        <Parameter>brigade</Parameter>)
      </Para>

      <bridgehead renderas=sect3>Arguments</bridgehead>
      <Para>
        <ItemizedList>
        <ListItem><Para>
          <Parameter>dir_cfg</Parameter>
          - Directory configuration, as returned by calls to the 
          create_dir_config and merge_dir_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>svr_cfg</Parameter>
          - Server configuration, as returned by calls to the create_svr_config
          and merge_svr_config hooks.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>filter</Parameter>
          - Information about the current running filter.  This object contains
          many attributes.  See <xref linkend="filter-api">.
        </Para></ListItem>
        <ListItem><Para>
          <Parameter>brigade</Parameter>
          - A bucket brigade of data to be filtered.  
          See <xref linkend="brigade-api">
        </Para></ListItem>
        </ItemizedList>
      </Para>

      <bridgehead renderas=sect3>Return Value</bridgehead>
      <Para>
        The return value should be 0 on success, -1 to indicate failure.
      </Para>

      <bridgehead renderas=sect3>Description</bridgehead>
      <Para>
        <Parameter>output_filter</Parameter> is only a prototype for the
        <Parameter>callback</Parameter> to register_output_filter.  In order
        for this callback to ever be invoked, it must be added to the filter
        chain via <link linkend="add-output-filter">add_output_filter</link>.
      </Para>
    </Sect3>
  </Sect2>
</sect1>  

<Sect1 id="misc-api"><Title>mod_snake Misc API</Title>
  <Para>
    The mod_snake Misc API is available as methods within the mod_snake
    module. These methods don't really fit in anywhere else.. ;-)
  </Para>

  <Sect2><Title>get_version</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
      <Para><Command>mod_snake.get_version</Command>()
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      This method returns version information about mod_snake, in the same
      fashion as the Apache server-string. The result is of the form: 
      ``mod_snake/version'', where version is generally something like 
      ``0.1.0'', etc.
    </Para>
  </Sect2>

  <Sect2><Title>get_modules</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
      <Para><Command>mod_snake.get_modules</Command>()
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      This method returns a list of all the modules loaded into the server.
      The list contains objects of type ModSnakePyMod
    </Para>
  </Sect2>

</Sect1>

<Sect1 id="apache-api"><Title>mod_snake Apache API</Title>
  <Para>
    The mod_snake Apache API is available as methods within the mod_snake
    module. The mod_snake module can be imported into any Python module,
    and the routines accessed directly. The Apache API contains routines
    which should be accessable by regular modules, CGIs, and embedded
    Python.
  </Para>

  <Sect2><Title>ap_server_root_relative</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>mod_snake.ap_server_root_relative</Command>(
      <Parameter>path</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>path</Parameter>
        - (type string) A path (relative or absolute) to convert, relative
        to the server's root directory.
      </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      The return value is a new string, containing the absolute path on the
      filesystem. For example, if the server's root directory was 
      /home/jtravis/apache, then ap_server_root_relative('logs/mylog') would 
      return /home/jtravis/apache/logs/mylog.
    </Para>
  </Sect2>

  <Sect2><Title>ap_log_error</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>mod_snake.ap_log_error</Command>(
      <Parameter>level</Parameter>,
      <Parameter>server</Parameter>,
      <Parameter>err_string</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>level</Parameter>
        - A level, indicating the severity of the error. Possible values
        are: APLOG_EMERG, APLOG_ALERT, APLOG_CRIT, APLOG_ERR, APLOG_WARNING,
        APLOG_NOTICE, APLOG_INFO, APLOG_DEBUG, all of which are available
        as attributes within the mod_snake module.
      </Para></ListItem>
      <ListItem><Para>
        <Parameter>server</Parameter>
        - A server_rec object where the error occurred, or None
      </Para></ListItem>
      <ListItem><Para>
        <Parameter>err_string</Parameter>
        - A string (with no terminating '\n') description of the
        error to be logged.
      </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      No values are returned from this function.
    </Para>
  </Sect2>

  <Sect2><Title>ap_getwords_conf</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>mod_snake.ap_getwords_conf</Command>(
    <Parameter>str</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>str</Parameter>
        - a string to parse as arguments to a configuration directive.
      </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      A list containing elements of the split-up str is returned.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      Apache uses the ap_getword_conf routine to obtain a new argument to
      a configuration directive. Arguments may be quoted strings or plain
      strings. The ap_getwords_conf routine returns a list of arguments
      as parsed from the str argument.
    </Para>
  </Sect2>


  <Sect2><Title>ap_get_server_version</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>mod_snake.ap_get_server_version</Command>()
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      Returns a string containing the Apache server version
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      The server version as returned by the function is the same that is
      sent to clients via the server string. The common form of the 
      server-version is ``Apache/version''. e.g.: ``Apache/2.0a3''
    </Para>
  </Sect2>

  <Sect2><Title>ap_validate_password</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>mod_snake.ap_validate_password</Command>(pword, hashed)
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      Returns a true value of the hashed argument is a hashed representation
      of the password, else false.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine compares a plaintext password with a hashed password (which
      is often created with the htpasswd program, for instance).  Hashed 
      passwords are often stored in a database or file as opposed to their
      plaintext counterparts.  This provides safety against theft of the
      password file.
    </Para>

  </Sect2>

</Sect1>

<Sect1 id="request-api"><Title>request_rec API</Title>
  <Para>
    The request record is what Apache passes to most of the phase handlers. 
  </Para>

  <Sect2><Title>send_http_header</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.send_http_header</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      Before content data is sent to the client, headers must be sent. Modules
      which choose to handle the entire content_handler phase by themselves,
      must call this routine prior to sending content. The headers sent
      are setup within the request_rec's headers_in and headers_out 
      dictionaries. Other fields such as content_type and status are also 
      used when send_http_header() generates its response.
    </Para>
  </Sect2>

  <Sect2><Title>add_cgi_vars</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.add_cgi_vars</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine is equivalent to the Apache ap_add_cgi_vars(), which adds
      commonly used CGI environment variables to the request's subprocess_env
      dictionary.
    </Para>
  </Sect2>

  <Sect2><Title>add_common_vars</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.add_common_vars</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine is equivalent to the Apache ap_add_common_vars(), which
      adds common CGI environment variables to the request's subprocess_env
      dictionary.
    </Para>
  </Sect2>

  <Sect2><Title>get_basic_auth_pw</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.get_basic_auth_pw</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine returns a tuple (rescode, pword), where rescode is one
      of mod_snake.HTTP_INTERNAL_SERVER_ERROR, mod_snake.HTTP_UNAUTHORIZED,
      mod_snake.OK, or mod_snake.DECLINED. If rescode is mod_snake.OK, pword
      will be a string password passed by the client, else it will be None.
    </Para>
  </Sect2>

  <Sect2><Title>requires</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.requires</Command>()
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      This routine returns a tuple containing a number of require_line objects.
      Each require_line object contains requirement and method_mask attributes.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      When Apache processes 'Require' directives, the values are added to
      an internal array. PyMods may access this array via the requires()
      function. The objects returned contain a requirement attribute, 
      designating the value passed to the 'Require' directive, and a 
      method_mask indicating the limit imposed on the requirement as 
      designated by the &lt;Limit&gt; directives.
    </Para>
  </Sect2>

  <Sect2><Title>note_auth_failure</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.note_auth_failure</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine is a wrapper around the 
      request_rec.note_basic_auth_failure(),
      and request_rec.note_digest_auth_failure() functions. Either of them,
      or none may be called depending on the authentication type of the
      request.
    </Para>
  </Sect2>

  <Sect2><Title>note_basic_failure</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.note_basic_auth_failure</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine makes modifications to the outgoing client error headers.
      It will add the WWW-Authenticate header, or the Proxy-Authenticate
      header, depending on the type of request.
    </Para>
  </Sect2>

  <Sect2><Title>note_digest_failure</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.note_digest_auth_failure</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine makes modifications to the outgoing client error headers.
      It will add the WWW-Authenticate header, or the Proxy-Authenticate
      header, depending on the type of request.
    </Para>
  </Sect2>

  <Sect2><Title>send_http_trace</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.send_http_trace</Command>()
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      This routine returns mod_snake.OK on success, and a mod_snake.HTTP_*
      error on failure.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine sends a copy of the clients request back to the client,
      including header and body information.
    </Para>
  </Sect2>


  <Sect2><Title>ap_rwrite</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.rwrite</Command>(
    <Parameter>str</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
      <Parameter>str</Parameter>
        - data to write to the remote client.
      </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      Returns an integer designating how many bytes were written.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      The rwrite function is one of the main ways that PyMods can communicate
      information back to the remote client. This routine sends all data
      passed in through all of Apache's internal routines for buffering
      and filtering.  Under Apache 2.0, this method is still available, but
      buffers data internally before converting it to a bucket in a brigade.
      <Warning><Para>
        Modules should never use both rwrite calls and bucket brigades to
        write to a client.  Since rwrite calls are buffered internally, 
        data may be sent out of order if they are mixed.</Para></Warning>
    </Para>
  </Sect2>

  <Sect2><Title>setup_client_block</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.setup_client_block</Command>(
    <Parameter>policy</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
      <Parameter>policy</Parameter>
      - One of the pre-defined policies
      </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      The return value is one of the standard hook return values in 
      <xref linkend="table-standard-hook-returns">.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      The read policy argument is one of:
      <Table id="table-read-policy"><Title>Read Policies</Title>
        <TGroup cols="2">
        <colspec colname="argument">
        <colspec colname="description">
        <THead>
          <row><entry>Argument</Entry><Entry>Description</Entry></row>
        </THead>
        <TBody> 
          <row>
            <entry>REQUEST_NO_BODY</entry>
            <entry>Send 413 error if message has any body</entry>
          </row>
          <row>
            <entry>REQUEST_CHUNKED_ERROR</entry>
            <entry>Send 411 error if body without Content-Length</entry>
          </row>
          <row>
            <entry>REQUEST_CHUNKED_DECHUNK</entry>
            <entry>If chunked, remove the chunks for the caller</entry>
          </row>
        </TBody>
        </TGroup>
      </Table>
    </Para><Para>
      This routine sets up the policy for how subsequent reads via 
      should_client_block, and get_client_block are performed.
    </Para>
  </Sect2>

  <Sect2><Title>should_client_block</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.should_client_block</Command>()
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      This method will return 0 if there is no data to be read, otherwise
      it will return 1.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This method is an intermediate step between the setup of the client
      block, and getting the client blocks. It ensures that 100 Continue
      responses are sent appropriately. This function should never be called
      more than once per request.
    </Para>
  </Sect2>

  <Sect2><Title>get_client_block</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.get_client_block</Command>(
    <Parameter>len</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
      <Parameter>len</Parameter>
      - Number of bytes to read.
      </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      This method returns a tuple containing a (data, datalen) pair -- the
      data read, and the length of the data. On error, 'data' will be Py_None.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This method gets client sent information. It takes care of chunking,
      as per the setup_client_block.
    </Para>
  </Sect2>

  <Sect2><Title>discard_request_body</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.discard_request_body</Command>()
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      Returns one of the standard hook return values in
      <xref linkend="table-standard-hook-returns">.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      In the case where a handler does not want to deal with a request body,
      this routine can be called to safely discard it. This is especially
      useful, as to not disrupt persistant connections.
    </Para>
  </Sect2>

  <Sect2 id="add-output-filter"><Title>add_output_filter</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.add_output_filter</Command>(
    <Parameter>filtername</Parameter>,
    <Parameter>callback_data</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
      <Parameter>filtername</Parameter>
      - Name of filter to add.
      </Para></ListItem>
      <ListItem><Para>
      <Parameter>callback_data</Parameter>
      - Callback data to send to the filter function.
      </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Compatability</bridgehead>
    <Para>
      This method is only available when mod_snake is running on an Apache
      2.0 server.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This method is used to add a filter to the filter chain.  The filter
      must first be registered via register_output_filter 
      (see <xref linkend="register-output-filter">).  The callback data is
      available within the filter function as filter.ctx.
    </Para>
  </Sect2>

  <Sect2 id="request-rec-brigade-create"><Title>brigade_create</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.brigade_create</Command>()
    </Para>

    <bridgehead renderas=sect3>Compatability</bridgehead>
    <Para>
      This method is only available when mod_snake is running on an Apache
      2.0 server.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This method creates a new brigade (see <xref linkend="brigade-api">).
    </Para>
  </Sect2>

  <Sect2><Title>output_filters</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.output_filters</Command>
    </Para>

    <bridgehead renderas=sect3>Compatability</bridgehead>
    <Para>
      This hook is only available when mod_snake is running on an Apache
      2.0 server.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute contains a reference to the chain of filters that are
      scheduled to process data.  Content generation phases can call the
      pass_brigade method of this object to send data to the client.
    </Para>
  </Sect2>

  <Sect2><Title>connection</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.connection</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute contains a reference to the connection associated with
      the incoming request. 
    </Para>
  </Sect2>

  <Sect2><Title>server</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.server</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute contains a reference to the server that the incoming
      request came in on.
    </Para>
  </Sect2>

  <Sect2><Title>next</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.next</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      If the request ends up getting redirected, this attribute points to
      the request that it was directed to.
    </Para>
  </Sect2>

  <Sect2><Title>prev</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.prev</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      If the current request is an internal redirect, this attribute points
      to the request it came from.
    </Para>
  </Sect2>

  <Sect2><Title>main</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.main</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      If this request is a sub request, this attribute points back to the
      main request.
    </Para>
  </Sect2>

  <Sect2><Title>the_request</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.the_request</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute contains the first line of the request. Example: 'GET
      /foo/bar.html HTTP/1.0'
    </Para>
  </Sect2>

  <Sect2><Title>header_only</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.header_only</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute is a true/false indicating whether or not it is a HEAD
      request
    </Para>
  </Sect2>

  <Sect2><Title>protocol</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.protocol</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute is a string containing the protocol sent by the client,
      otherwise HTTP/0.9
    </Para>
  </Sect2>

  <Sect2><Title>proto_num</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.proto_num</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute is an integer representing the protocol number, as sent
      by the client. Example: HTTP/0.9 == 9, HTTP/1.1 == 1001
    </Para>
  </Sect2>

  <Sect2><Title>hostname</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.hostname</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute contains the hostname, as set by the Host: header, or
      the full URI. If not given, it is 'None'
    </Para>
  </Sect2>

  <Sect2><Title>status_line</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.status_line</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute may be set by the module to return a specialized
      status-line back to the client.
    </Para>
  </Sect2>

  <Sect2><Title>status</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.status</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This integer attribute may be set byt he module to return a specific
      status number back to the client.
    </Para>
  </Sect2>

  <Sect2><Title>method</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.method</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the method as set by the client. Example:
      GET, HEAD, FOO, etc.
    </Para>
  </Sect2>

  <Sect2><Title>method_number</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.method_number</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute holds an integer value representing the method as sent
      by the client. The following values are the ones recognized by the
      server, and are properties of the mod_snake module: M_GET, M_PUT,
      M_POST, M_DELETE, M_CONNECT, M_OPTIONS, M_TRACE, M_PATCH, M_PROPFIND,
      M_PROPPATCH, M_MKCOL, M_COPY, M_MOVE, M_LOCK, M_UNLOCK, M_INVALID.
      Note that M_GET is valid for both GET and HEAD methods.
    </Para>
  </Sect2>

  <Sect2><Title>headers_in</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.headers_in</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This dictionary attribute contains the MIME headers as specified by
      the client.
    </Para>
  </Sect2>

  <Sect2><Title>headers_out</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.headers_out</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This dictionary attribute contains the MIME headers that will be sent
      out to the client when the send_http_header method is called.
    </Para>
  </Sect2>

  <Sect2><Title>notes</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.notes</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This dictionary attribute provides storage for modules on a 
      <emphasis>per request</emphasis> basis.  Modules can store any data they
      wish in this dictionary, however it will be unavailable for subsequent
      requests.  This storage can be useful when a module needs to keep
      per-request information in between different handlers (such as the
      fixups and content-handlers.)
    </Para>
  </Sect2>

  <Sect2><Title>content_type</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.content_type</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the content type as established by the
      Apache type-checker phase, or None before the type-checker phase is
      called.  Example: "text/html"
    </Para>
  </Sect2>

  <Sect2><Title>content_encoding</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.content_encoding</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the encoding of the content.
    </Para>
  </Sect2>

  <Sect2><Title>handler</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.handler</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the handler to be dispatched on for
      the content-handler, else None.
    </Para>
  </Sect2>

  <Sect2><Title>user</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.user</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the user name if authentication was
      made, else None.
    </Para>
  </Sect2>

  <Sect2><Title>ap_auth_type</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.ap_auth_type</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the authentication type if authentication
      was made, else None. Example: 'basic', 'digest', etc.
    </Para>
  </Sect2>

  <Sect2><Title>unparsed_uri</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.unparsed_uri</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the unparsed URI.
    </Para>
  </Sect2>

  <Sect2><Title>uri</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.uri</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the path portion of the URI.
    </Para>
  </Sect2>

  <Sect2><Title>filename</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.filename</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the filename portion of the requested URI.
    </Para>
  </Sect2>

  <Sect2><Title>path_info</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.path_info</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the path information of the requested
      URI, with no appended filename. If there is no path, this attribute
      is 'None'
    </Para>
  </Sect2>

  <Sect2><Title>args</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.args</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the query arguments from the URI if
      given, else None.  This string can be passed to cgi.py's parse_qs()
      function to turn it into a dictionary of values.  
      <Note><Title>cgi.py</Title>
      <Para>cgi.py is distributed with all Python distributions.</Para></Note>
    </Para>
  </Sect2>

  <Sect2><Title>finfo</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>request_rec.finfo</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      If the requested document is a real file, this attribute contains a
      tuple from the stat(). The tuple is the same as returned by the os.stat
      function, and contains the following elements: (mode, inode, device,
      number_links, uid, guid, size, atime, mtime, ctime)
    </Para>
  </Sect2>
</Sect1>

<Sect1 id="server-api"><Title>server_rec API</Title>
  <Para>
    The server records that Apache uses contain a ton of useful information.
    While modules do not generally use all of these attributes, some of
    them are fairly useful and important.
  </Para>

  <Sect2><Title>next</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>server_rec.next</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      Within the Apache webserver, many virtual-hosts can be run 
      simultaneously. The servers are stored in a linked list within the 
      server, and the next attribute returns the next server in the list.
    </Para>
  </Sect2>

  <Sect2><Title>def_name</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>server_rec.def_name</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the definition name of the server, as
      from the configuration file. In the case of the main server, this
      value is None
    </Para>
  </Sect2>

  <Sect2><Title>defn_line_number</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>server_rec.defn_line_number</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This integer attribute contains the line number of the VirtualHost
      directive for which the server was created.
    </Para>
  </Sect2>

  <Sect2><Title>server_admin</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>server_rec.server_admin</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute contains the server admin string, as specified within
      the configuration file by the ServerAdmin directive.
    </Para>
  </Sect2>

  <Sect2><Title>server_hostname</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>server_rec.server_hostname</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute contains the server hostname string, as specified within
      the configuration file by the ServerName directive.
    </Para>
  </Sect2>

  <Sect2><Title>port</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>server_rec.port</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute contains the port number that the server is running on.
    </Para>
  </Sect2>

  <Sect2><Title>is_virtual</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>server_rec.is_virtual</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      Attribute specifying whether or not a given server is a virtual server
      or not (true or false)
    </Para>
  </Sect2>

  <Sect2><Title>path</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>server_rec.path</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      Attribute specifying the pathname, as given by the ServerPath directive
      within the configuration file.
    </Para>
  </Sect2>

  <Sect2><Title>names</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>server_rec.names</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      Returns a tuple containing the names as denoted by ServerAlias
    </Para>
  </Sect2>

  <Sect2><Title>wild_names</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>server_rec.wild_names</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      Returns a tuple containing the wildcarded names as denoted by 
      ServerAlias.
    </Para>
  </Sect2>

  <Sect2><Title>server_uid</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>server_rec.server_uid</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      Returns the effective user id when calling the exec wrapper
    </Para>
  </Sect2>

  <Sect2><Title>server_gid</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>server_rec.server_gid</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      Returns the effective group id when calling the exec wrapper.
    </Para>
  </Sect2>
</Sect1>

<Sect1 id="conn-api"><Title>conn_rec API</Title>
  <Para>
    Every incoming request to Apache has an associated conn_rec object
    which contains information about the connection. This object can also
    be used to directly read and write to the remote client.
  </Para>

  <Sect2><Title>base_server</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.base_server</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This attribute is a reference to a server_rec object on which the 
      connection came in.
    </Para>
  </Sect2>

  <Sect2><Title>local_addr</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.local_addr</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the local address that the request came
      in on. Example: 127.0.0.1
    </Para>
  </Sect2>

  <Sect2><Title>remote_addr</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.remote_addr</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the remote address of the incoming 
      connection.  Example: 69.0.0.1
    </Para>
  </Sect2>

  <Sect2><Title>write</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.write</Command>(
      <Parameter>the_skinny</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>the_skinny</Parameter>
        - string data to write to the remote client
        </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      Returns a tuple (status, nbytes), where status is one of the APR error
      codes in the mod_snake module, and nbytes are the number of bytes
      successfully written.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      Occasionally a module writer may wish to write directly to the remote
      connection, such as when using a protocol other than HTTP. This routine
      allows the module to communicate directly with the remote client.
    </Para>

  </Sect2>


  <Sect2><Title>read</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.read</Command>(
      <Parameter>nbytes</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>nbytes</Parameter>
        - The number of bytes to read
        </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Return Value</bridgehead>
    <Para>
      Returns a tuple (status, nbytes, data) where status is one of the APR
      error codes in the mod_snake module, nbytes is the number of bytes
      read, and data is the actual data read from the client.
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This method allows modules to read data from the remote client. 
    </Para>
  </Sect2>

  <Sect2><Title>flush</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.flush</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This method flushes the buffered output, as sent from conn_rec.write()
    </Para>
  </Sect2>

  <Sect2><Title>remote_ip</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.remote_ip</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the remote IP address of the incoming
      connection. Example: 127.0.0.1
    </Para>
  </Sect2>

  <Sect2><Title>keepalive</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.keepalive</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This integer attribute indicates whether or not HTTP keep-alive is
      in effect for the current connection. -1 indiciates a fatal error,
      0 undecided, and 1 yes.
    </Para>
  </Sect2>

  <Sect2><Title>keptalive</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.keptalive</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This true/false attribute indicates whether or not HTTP keep-alive
      was used during the request.
    </Para>
  </Sect2>

  <Sect2><Title>double_reverse</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.double_reverse</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This integer attribute indicates whether or not double-reverse DNS
      has been performed. -1 = failure, 0 = not yet, 1 = yes
    </Para>
  </Sect2>

  <Sect2><Title>keepalives</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.keepalives</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This integer attribute indicates how many times this connection has
      been used for requests.
    </Para>
  </Sect2>

  <Sect2><Title>local_ip</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.local_ip</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the IP of the server that the connection
      came in on.
    </Para>
  </Sect2>

  <Sect2><Title>local_host</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.local_host</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the hostname of the server that the
      connection came in on.
    </Para>
  </Sect2>

  <Sect2><Title>id</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>conn_rec.id</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This integer attribute contains a unique ID at any given time.
    </Para>
  </Sect2>

</Sect1>


<Sect1 id="filter-api"><Title>filter API</Title>
  <Para>
    Under Apache 2.0, modules have the ability to filter content before
    sending it to the remote client.  This incorporates several different
    APIs.  First, the module must register the filter via the 
    register_output_filter method 
    (see <xref linkend="register-output-filter">).  Secondly, the PyMod must
    add the hook to the filter chain somewhere within the request phase.  For
    output filters, this is commonly done at either post read request time, or
    in the insert_filters hook.  Lastly, when the filter is called, it must
    utilitize both the filter API, and the bucket brigade API to manipulate
    content before sending it to the client or next filter.
  </Para>

  <Sect2><Title>name</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>filter.name</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute contains the name of the filter, as specified when
      calling register_output_filter. 
      (See <xref linkend="register-output-filter">)
    </Para>
  </Sect2>

  <Sect2><Title>pass_brigade</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>filter.pass_brigade</Command>(
      <Parameter>brigade</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>brigade</Parameter>
        - The bucket brigade to pass down the filter chain.
        </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      When a filter is to be given a new chunk of data to process, whether
      from a content generator, or another filter, this routine can be called
      to start the processing.  Subsequent filters should pass the data down
      the chain until the data is either written to the client, discarded, or
      buffered.
    </Para>
  </Sect2>


  <Sect2><Title>next</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>filter.next</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      The <Parameter>next</Parameter> attribute points to the next filter
      in the filter chain.  This is commonly used from within a filter, to
      pass the brigade on to the next filter.
    </Para>
  </Sect2>

  <Sect2><Title>ctx</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>filter.ctx</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      The <Parameter>ctx</Parameter> parameter contains callback data, as
      given by the PyMod, when the filter was added.  
      (See <xref linkend="add-output-filter">)
    </Para>
  </Sect2>

  <Sect2><Title>r</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>filter.r</Command>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      The current request_rec object that the filter is processing.
    </Para>
  </Sect2>

</Sect1>

<Sect1 id="brigade-api"><Title>brigade API</Title>
  <Para>
    Under Apache 2.0, modules can generate, filter, and discard content.  This
    content comes in the form of bucket brigades.  A bucket brigade is simply
    a list of several 'buckets.'  Each bucket contains data.  The reason that
    the data is dispersed into these packets is that a module may make a 
    specific optimization with respect to that data - Such as, that it may be
    mmap()ed, or static data.  The brigade API allows modules to manipulate
    the brigades, and the data stored within.  Brigades last the lifetime of
    the object that creates them.  Buckets may or may not have a different
    lifetime.  Brigade creation for request output filters is done in
    the request_rec (See <xref linkend="request-rec-brigade-create">).
  </Para>

  <Sect2><Title>get_head</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>brigade.get_head</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine returns the first bucket in the bucket brigade. 
      If the brigade is empty, this returns <literal>None</literal>.
    </Para>
  </Sect2>

  <Sect2><Title>get_tail</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>brigade.get_tail</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine returns the last bucket in the bucket brigade. 
      If the brigade is empty, this returns <literal>None</literal>.
    </Para>
  </Sect2>


  <Sect2><Title>get_next</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>brigade.get_next</Command>(
      <Parameter>bucket</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>bucket</Parameter>
        - A bucket to get the next one after.
        </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine returns the next bucket after the passed in bucket
      argument.  If there is no bucket after the argument, the return
      value is <literal>None</literal>
    </Para>
  </Sect2>


  <Sect2><Title>get_prev</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>brigade.get_prev</Command>(
      <Parameter>bucket</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>bucket</Parameter>
        - A bucket to get the previous one of.
        </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine returns the previous bucket before the passed in bucket
      argument.  If there is no bucket before the argument, the return
      value is <literal>None</literal>
    </Para>
  </Sect2>

  <Sect2><Title>move_head</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>brigade.move_head</Command>(
      <Parameter>bucket</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>bucket</Parameter>
        - A bucket to move to the head of the brigade.
        </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine can either move a bucket from a totally seperate brigade
      into the head of the called brigade, or move a bucket currently in the
      brigade to the head.
    </Para>
  </Sect2>

  <Sect2><Title>move_tail</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>brigade.move_tail</Command>(
      <Parameter>bucket</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>bucket</Parameter>
        - A bucket to move to the tail of the brigade.
        </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine can either move a bucket from a totally seperate brigade
      into the tail of the called brigade, or move a bucket currently in the
      brigade to the tail.
    </Para>
  </Sect2>

  <Sect2><Title>move_before</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>brigade.move_before</Command>(
      <Parameter>before</Parameter>,
      <Parameter>bucket</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>before</Parameter>
        - The sentinel bucket.  The moved bucket will be moved before this
          one.
        </Para></ListItem>
      <ListItem><Para>
        <Parameter>bucket</Parameter>
        - The bucket to move.
      </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine moves the <Parameter>bucket</Parameter> to a position prior
      to '<Parameter>before</Parameter>'.  This method can also move buckets
      between different brigades, if <Parameter>bucket</Parameter>, and 
      <Parameter>before</Parameter> are in different brigades.
    </Para>
  </Sect2>

  <Sect2><Title>move_after</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>brigade.move_after</Command>(
      <Parameter>after</Parameter>,
      <Parameter>bucket</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>before</Parameter>
        - The sentinel bucket.  The moved bucket will be moved after this one.
        </Para></ListItem>
      <ListItem><Para>
        <Parameter>bucket</Parameter>
        - The bucket to move.
        </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine moves the <Parameter>bucket</Parameter> to a position after
      '<Parameter>after</Parameter>'.  This method can also move buckets
      between different brigades, if <Parameter>bucket</Parameter>, and 
      <Parameter>after</Parameter> are in different brigades.
    </Para>
  </Sect2>

  <Sect2><Title>remove</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>brigade.move_after</Command>(
      <Parameter>bucket</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>bucket</Parameter>
        - The bucket to remove.
        </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine removes a bucket from the brigade.  The removed bucket is
      no longer accessable from the brigade, but may continue to exist 
      internally, if other brigades are accessing it.
    </Para>
  </Sect2>

  <Sect2><Title>bucket_create_simple</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>brigade.bucket_create_simple</Command>(
      <Parameter>data</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>data</Parameter>
        - The data value of the new bucket.
        </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This is the main routine for creation of new buckets.  The 
      <Parameter>data</Parameter> passed in will be available to other filters
      or other modules accessing the brigade.  In Apache 2.0, this is one of 
      the primary methods of generating data for the client.
    </Para>
  </Sect2>

  <Sect2><Title>bucket_create_eos</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>brigade.bucket_create_eos</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This routine creates a special <literal>eos</literal> bucket.  This
      bucket indicates that it is the end of the stream.  This triggers
      subsequent filters to assume that no more data will be sent after the
      <literal>eos</literal> bucket is sent.
    </Para>
  </Sect2>
</Sect1>

<Sect1 id="bucket-api"><Title>bucket API</Title>
  <Para>
    One of the fundamental blocks for moving data to the client comes in the
    form of the bucket brigade (See <xref linkend="brigade-api">).  The brigade
    is simply an ordered list of buckets.  
  </Para>

  <Sect2><Title>is_eos</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>bucket.is_eos</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This integer attribute indicates whether or not the bucket is an
      <literal>EOS</literal> (end of stream) bucket.  If 
      <parameter>is_eos</parameter> is true, the bucket is 
      <literal>EOS</literal>,
      otherwise it is a regular bucket.
    </Para>
  </Sect2>

  <Sect2><Title>name</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>bucket.name</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This string attribute gives the internally defined name of the
      bucket type.
    </Para>
  </Sect2>

  <Sect2><Title>length</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>bucket.length</Command>()
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This integer attribute contains the length of the data stored in the
      bucket.  It can equal <literal>-1</literal>, indicating that the length
      of the data cannot be determined until it is read.  Values other than
      <literal>-1</literal> indicate the length of the data that will be 
      read.  If <Parameter>length</Parameter> is <literal>-1</literal>, bucket
      data must be read until <literal>None</literal> is returned.
    </Para>
  </Sect2>

  <Sect2><Title>read</Title>
    <bridgehead renderas=sect3>Synopsis</bridgehead>
    <Para><Command>bucket.read</Command>(
      <Parameter>block</Parameter>)
    </Para>

    <bridgehead renderas=sect3>Arguments</bridgehead>
    <Para>
      <ItemizedList>
      <ListItem><Para>
        <Parameter>block</Parameter>
        - Integer value indicating whether or not this routine should block
        when trying to read data.
        </Para></ListItem>
      </ItemizedList>
    </Para>

    <bridgehead renderas=sect3>Description</bridgehead>
    <Para>
      This is the main routine for transferring data from the bucket to the
      caller.  If the <Parameter>block</Parameter> parameter is given, this
      routine will block until the data has been read.  If the bucket's
      length is <literal>-1</literal> this routine will return 
      <literal>None</literal> when there is no more data to be read.  
    </Para>
  </Sect2>
</Sect1>
</Article>