<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>4.5.1 Functions</title> <META NAME="description" CONTENT="4.5.1 Functions"> <META NAME="keywords" CONTENT="modpython"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <link rel="STYLESHEET" href="modpython.css"> <link rel="first" href="modpython.html"> <link rel="contents" href="contents.html" title="Contents"> <link rel="index" href="genindex.html" title="Index"> <LINK REL="next" href="pyapi-mptable.html"> <LINK REL="previous" href="module-apache.html"> <LINK REL="up" href="module-apache.html"> <LINK REL="next" href="pyapi-mptable.html"> </head> <body> <DIV CLASS="navigation"> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td><A href="module-apache.html"><img src="icons/previous.png" border="0" height="32" alt="Previous Page" width="32"></A></td> <td><A href="module-apache.html"><img src="icons/up.png" border="0" height="32" alt="Up One Level" width="32"></A></td> <td><A href="pyapi-mptable.html"><img src="icons/next.png" border="0" height="32" alt="Next Page" width="32"></A></td> <td align="center" width="100%">Mod_python Manual</td> <td><A href="contents.html"><img src="icons/contents.png" border="0" height="32" alt="Contents" width="32"></A></td> <td><img src="icons/blank.png" border="0" height="32" alt="" width="32"></td> <td><A href="genindex.html"><img src="icons/index.png" border="0" height="32" alt="Index" width="32"></A></td> </tr></table> <b class="navlabel">Previous:</b> <a class="sectref" href="module-apache.html">4.5 apache - Access</A> <b class="navlabel">Up:</b> <a class="sectref" href="module-apache.html">4.5 apache - Access</A> <b class="navlabel">Next:</b> <a class="sectref" href="pyapi-mptable.html">4.5.2 Table Object (mp_table) </A> <br><hr> </DIV> <!--End of Navigation Panel--> <H2><A NAME="SECTION006510000000000000000"> </A> <BR> 4.5.1 Functions </H2> <P> <dl><dt><b><a name="l2h-19"><tt class="function">log_error</tt></a></b>(<var>message</var><big>[</big><var>, level, server</var><big>]</big>) <dd> An interface to the Apache <code>ap_log_error()</code> function. <var>message</var> is a string with the error message, <var>level</var> is one of the following flags constants: <P> <dl><dd><pre class="verbatim"> APLOG_EMERG APLOG_ALERT APLOG_CRIT APLOG_ERR APLOG_WARNING APLOG_NOTICE APLOG_INFO APLOG_DEBUG APLOG_NOERRNO </pre></dl> <P> <var>server</var> is a reference to a <tt class="member">req.server</tt> object. If <var>server</var> is not specified, then the error will be logged to the default error log, otherwise it will be written to the error log for the appropriate virtual server. When <var>server</var> is not specified, the setting of LogLevel does not apply, the LogLevel is dictated by an httpd compile-time default, usually <code>warn</code>. <P> If you have a reference to a request object available, consider using <tt class="method">req.log_error</tt> instead, it will prepend request-specific information such as the source IP of the request to the log entry. </dl> <P> <dl><dt><b><a name="l2h-20"><tt class="function">import_module</tt></a></b>(<var>module_name</var><big>[</big><var>, autoreload=1, log=0, path=None</var><big>]</big>) <dd> This function can be used to import modules taking advantage of mod_python's internal mechanism which reloads modules automatically if they have changed since last import. <P> <var>module_name</var> is a string containing the module name (it can contain dots, e.g. <code>mypackage.mymodule</code>); <var>autoreload</var> indicates whether the module should be reloaded if it has changed since last import; when <var>log</var> is true, a message will be written to the logs when a module is reloaded; <var>path</var> allows restricting modules to specific paths. <P> Example: <P> <dl><dd><pre class="verbatim"> from mod_python import apache mymodule = apache.import_module('mymodule', log=1) </pre></dl> </dl> <P> <dl><dt><b><a name="l2h-21"><tt class="function">allow_methods</tt></a></b>(<big>[</big><var>*args</var><big>]</big>) <dd> A convenience function to set values in <tt class="member">req.allowed</tt>. <tt class="member">req.allowed</tt> is a bitmask that is used to construct the "<tt class="samp">Allow:</tt>" header. It should be set before returning a <code>HTTP_NOT_IMPLEMENTED</code> error. <P> Arguments can be one or more of the following: <dl><dd><pre class="verbatim"> 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_VERSION_CONTROL M_CHECKOUT M_UNCHECKOUT M_CHECKIN M_UPDATE M_LABEL M_REPORT M_MKWORKSPACE M_MKACTIVITY M_BASELINE_CONTROL M_MERGE M_INVALID </pre></dl> <P> </dl> <P> <dl><dt><b><a name="l2h-22"><tt class="function">config_tree</tt></a></b>() <dd> Returns the server-level configuration tree. This tree does not include directives from .htaccess files. This is a <i>copy</i> of the tree, modifying it has no effect on the actual configuration. </dl> <P> <dl><dt><b><a name="l2h-23"><tt class="function">server_root</tt></a></b>() <dd> Returns the value of ServerRoot. </dl> <P> <dl><dt><b><a name="l2h-24"><tt class="function">make_table</tt></a></b>() <dd> This function is obsolete and is an alias to <tt class="class">table</tt> (see below). </dl> <P> <dl><dt><b><a name="l2h-25"><tt class="function">mpm_query</tt></a></b>(<var>code</var>) <dd> Allows querying of the MPM for various parameters such as numbers of processes and threads. The return value is one of three constants: <dl><dd><pre class="verbatim"> AP_MPMQ_NOT_SUPPORTED = 0 # This value specifies whether # an MPM is capable of # threading or forking. AP_MPMQ_STATIC = 1 # This value specifies whether # an MPM is using a static # of # threads or daemons. AP_MPMQ_DYNAMIC = 2 # This value specifies whether # an MPM is using a dynamic # of # threads or daemons. </pre></dl> <P> The <var>code</var> argument must be one of the following: <dl><dd><pre class="verbatim"> AP_MPMQ_MAX_DAEMON_USED = 1 # Max # of daemons used so far AP_MPMQ_IS_THREADED = 2 # MPM can do threading AP_MPMQ_IS_FORKED = 3 # MPM can do forking AP_MPMQ_HARD_LIMIT_DAEMONS = 4 # The compiled max # daemons AP_MPMQ_HARD_LIMIT_THREADS = 5 # The compiled max # threads AP_MPMQ_MAX_THREADS = 6 # # of threads/child by config AP_MPMQ_MIN_SPARE_DAEMONS = 7 # Min # of spare daemons AP_MPMQ_MIN_SPARE_THREADS = 8 # Min # of spare threads AP_MPMQ_MAX_SPARE_DAEMONS = 9 # Max # of spare daemons AP_MPMQ_MAX_SPARE_THREADS = 10 # Max # of spare threads AP_MPMQ_MAX_REQUESTS_DAEMON= 11 # Max # of requests per daemon AP_MPMQ_MAX_DAEMONS = 12 # Max # of daemons by config </pre></dl> <P> Example: <dl><dd><pre class="verbatim"> if apache.mpm_query(apache.AP_MPMQ_IS_THREADED): # do something else: # do something else </pre></dl> </dl> <P> <DIV CLASS="navigation"> <p><hr> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td><A href="module-apache.html"><img src="icons/previous.png" border="0" height="32" alt="Previous Page" width="32"></A></td> <td><A href="module-apache.html"><img src="icons/up.png" border="0" height="32" alt="Up One Level" width="32"></A></td> <td><A href="pyapi-mptable.html"><img src="icons/next.png" border="0" height="32" alt="Next Page" width="32"></A></td> <td align="center" width="100%">Mod_python Manual</td> <td><A href="contents.html"><img src="icons/contents.png" border="0" height="32" alt="Contents" width="32"></A></td> <td><img src="icons/blank.png" border="0" height="32" alt="" width="32"></td> <td><A href="genindex.html"><img src="icons/index.png" border="0" height="32" alt="Index" width="32"></A></td> </tr></table> <b class="navlabel">Previous:</b> <a class="sectref" href="module-apache.html">4.5 apache - Access</A> <b class="navlabel">Up:</b> <a class="sectref" href="module-apache.html">4.5 apache - Access</A> <b class="navlabel">Next:</b> <a class="sectref" href="pyapi-mptable.html">4.5.2 Table Object (mp_table) </A> <hr> <span class="release-info">Release 3.1.0a, documentation updated on August 26, 2003.</span> </DIV> <!--End of Navigation Panel--> </BODY> </HTML>