Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 15533144ea879a3ee7f2cdcbb31e4859 > files > 27

apache-mod_python-doc-3.3.1-12mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="modpython.css" type='text/css' />
<link rel="first" href="modpython.html" title='Mod_python Manual' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="dir-handlers-prrh.html" />
<link rel="prev" href="dir-handlers.html" />
<link rel="parent" href="dir-handlers.html" />
<link rel="next" href="dir-handlers-prrh.html" />
<meta name='aesop' content='information' />
<title>5.1.1 Python*Handler Directive Syntax</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.1 Request Handlers"
  href="dir-handlers.html"><img src='previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="5.1 Request Handlers"
  href="dir-handlers.html"><img src='up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="5.1.2 PythonPostReadRequestHandler"
  href="dir-handlers-prrh.html"><img src='next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Mod_python Manual</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='contents.png'
  border='0' height='32'  alt='Contents' width='32' /></A></td>
<td class='online-navigation'><img src='blank.png'
  border='0' height='32'  alt='' width='32' /></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='index.png'
  border='0' height='32'  alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="dir-handlers.html">5.1 Request Handlers</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="dir-handlers.html">5.1 Request Handlers</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="dir-handlers-prrh.html">5.1.2 PythonPostReadRequestHandler</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION007110000000000000000"></A><A NAME="dir-handlers-syn"></A>
<a id='l2h-267' xml:id='l2h-267'></a>
<BR>
5.1.1 Python*Handler Directive Syntax
</H2>

<P>
All request handler directives have the following syntax: 

<P>
<code>Python*Handler <em>handler [handler ...] [ | .ext [.ext ...] ] </em> </code>

<P>
Where <var>handler</var> is a callable object that accepts a single
argument - request object, and <var>.ext</var> is a file extension.

<P>
Multiple handlers can be specified on a single line, in which case
they will be called sequentially, from left to right. Same handler
directives can be specified multiple times as well, with the same
result - all handlers listed will be executed sequentially, from first
to last.

<P>
If any handler in the sequence returns a value other than <code>apache.OK</code>
or <code>apache.DECLINED</code>, then execution of all subsequent handlers for
that phase are aborted. What happens when either <code>apache.OK</code> or
<code>apache.DECLINED</code> is returned is dependent on which phase is
executing.

<P>
Note that prior to mod_python 3.3, if any handler in the sequence, no
matter which phase was executing, returned a value other than
<code>apache.OK</code>, then execution of all subsequent handlers for that phase
was aborted.

<P>
The list of handlers can optionally be followed by a <code>|</code> followed
by one or more file extensions. This would restrict the execution of
the handler to those file extensions only. This feature only works for
handlers executed after the trans phase.

<P>
A <em>handler</em> has the following syntax: 

<P>
<code>module[::object]</code>

<P>
Where <var>module</var> can be a full module name (package dot notation is
accepted) or an actual path to a module code file. The module is loaded
using the mod_python module importer as implemented by the
<code>apache.import_module()</code> function. Reference should be made to
the documentation of that function for further details of how module
importing is managed.

<P>
The optional <var>object</var> is the name of an object inside the module.
Object can also contain dots, in which case it will be resolved from
left to right. During resolution, if mod_python encounters an object
of type <code>&lt;class&gt;</code>, it will try instantiating it passing it a single
argument, a request object.

<P>
If no object is specified, then it will default to the directive of
the handler, all lower case, with the word "<tt class="samp">python</tt>"removed. E.g. the default object for PythonAuthenHandler would be
authenhandler.

<P>
Example: 

<P>
<div class="verbatim"><pre>
  PythonAuthzHandler mypackage.mymodule::checkallowed
</pre></div>

<P>
For more information on handlers, see Overview of a Handler.

<P>
Side note: The "<tt class="samp">::</tt>" was chosen for performance reasons. In order for
Python to use objects inside modules, the modules first need to be
imported. Having the separator as simply a "<tt class="samp">.</tt>", would considerably
complicate process of sequentially evaluating every word to determine
whether it is a package, module, class etc. Using the (admittedly
un-Python-like) "<tt class="samp">::</tt>" takes the time consuming work of figuring out
where the module part ends and the object inside of it begins away
from mod_python resulting in a modest performance gain.

<P>

<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.1 Request Handlers"
  href="dir-handlers.html"><img src='previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="5.1 Request Handlers"
  href="dir-handlers.html"><img src='up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="5.1.2 PythonPostReadRequestHandler"
  href="dir-handlers-prrh.html"><img src='next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Mod_python Manual</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='contents.png'
  border='0' height='32'  alt='Contents' width='32' /></A></td>
<td class='online-navigation'><img src='blank.png'
  border='0' height='32'  alt='' width='32' /></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='index.png'
  border='0' height='32'  alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="dir-handlers.html">5.1 Request Handlers</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="dir-handlers.html">5.1 Request Handlers</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="dir-handlers-prrh.html">5.1.2 PythonPostReadRequestHandler</A>
</div>
</div>
<hr />
<span class="release-info">Release 3.3.1, documentation updated on January 29, 2007.</span>
</DIV>
<!--End of Navigation Panel-->

</BODY>
</HTML>