/usr/share/doc/libapache2-mod-python-doc/doc-html/pyapi-apmeth.html is in libapache2-mod-python-doc 3.3.1-11.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 | <!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="pyapi-apmem.html" />
<link rel="prev" href="module-apache.html" />
<link rel="parent" href="module-apache.html" />
<link rel="next" href="pyapi-apmem.html" />
<meta name='aesop' content='information' />
<title>4.5.1 Functions</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="4.5 apache - Access"
href="module-apache.html"><img src='previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="4.5 apache - Access"
href="module-apache.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="4.5.2 Attributes"
href="pyapi-apmem.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="module-apache.html">4.5 apache - Access</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-apache.html">4.5 apache - Access</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="pyapi-apmem.html">4.5.2 Attributes</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION006510000000000000000"></A><A NAME="pyapi-apmeth"></A>
<BR>
4.5.1 Functions
</H2>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-31' xml:id='l2h-31' class="function">log_error</tt></b>(</nobr></td>
<td><var>message</var><big>[</big><var>, level, server</var><big>]</big><var></var>)</td></tr></table></dt>
<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>
<div class="verbatim"><pre>
APLOG_EMERG
APLOG_ALERT
APLOG_CRIT
APLOG_ERR
APLOG_WARNING
APLOG_NOTICE
APLOG_INFO
APLOG_DEBUG
APLOG_NOERRNO
</pre></div>
<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><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-32' xml:id='l2h-32' class="function">import_module</tt></b>(</nobr></td>
<td><var>module_name</var><big>[</big><var>, autoreload=None, log=None, path=None</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This function can be used to import modules.
<P>
<div class="note"><b class="label">Note:</b>
This function and the module importer were completely reimplemented in
mod_python 3.3. If you are using an older version of mod_python do not
rely on this documentation and instead refer to the documentation for
the specific version you are using as the new importer does not behave
exactly the same and has additional features.
<P>
If you are trying to port code from an older version of mod_python to
mod_python 3.3 and can't work out why the new importer is not working
for you, you can enable the old module importer for specific Python
interpreter instances by using:
<P>
<div class="verbatim"><pre>
PythonOption mod_python.legacy.importer name
</pre></div>
<P>
where 'name' is the name of the interpreter instance or '*' for it to
be applied to all interpreter instances. This option should be placed
at global context within the main Apache configuration files.
</div>
<P>
When using the <code>apache.import_module()</code> function, the
<var>module_name</var> should be a string containing either the module name,
or a path to the actual code file for the module; where a module is a
candidate for automatic module reloading, <var>autoreload</var> indicates
whether the module should be reloaded if it has changed since the last
import; when <var>log</var> is true, a message will be written to the logs
when a module is reloaded; <var>path</var> can be a list specifying additional
directories to be searched for modules.
<P>
With the introduction of mod_python 3.3, the default arguments for the
<var>autoreload</var> and <var>log</var> arguments have been changed to
<code>None</code>, with the arguments effectively now being unnecessary except
in special circumstances. When the arguments are left as the default of
<code>None</code>, the Apache configuration in scope at the time of the call
will always be consulted automatically for any settings for the
<code>PythonAutoReload</code> and <code>PythonDebug</code> directives respectively.
<P>
Example:
<P>
<div class="verbatim"><pre>
from mod_python import apache
module = apache.import_module('module_name')
</pre></div>
<P>
The <code>apache.import_module()</code> function is not just a wrapper for the
standard Python module import mechanism. The purpose of the function and
the mod_python module importer in general, is to provide a means of being
able to import modules based on their exact location, with modules being
distinguished based on their location rather than just the name of the
module. Distinguishing modules in this way, rather than by name alone,
means that the same module name can be used for handlers and other code
in multiple directories and they will not interfere with each other.
<P>
A secondary feature of the module importer is to implement a means of
having modules automatically reloaded when the corresponding code file
has been changed on disk. Having modules be able to be reloaded in this
way means that it is possible to change the code for a web application
without having to restart the whole Apache web server. Although this was
always the intent of the module importer, prior to mod_python 3.3, its
effectiveness was limited. With mod_python 3.3 however, the module
reloading feature is much more robust and will correctly reload parent
modules even when it was only a child module what was changed.
<P>
When the <code>apache.import_module()</code> function is called with just the
name of the module, as opposed to a path to the actual code file for the
module, a search has to be made for the module. The first set of
directories that will be checked are those specified by the <var>path</var>
argument if supplied.
<P>
Where the function is called from another module which had previously
been imported by the mod_python importer, the next directory which will
be checked will be the same directory as the parent module is located.
Where that same parent module contains a global data variable called
<code>__mp_path__</code> containing a list of directories, those directories
will also be searched.
<P>
Finally, the mod_python module importer will search directories
specified by the <code>PythonOption</code> called <code>mod_python.importer.path</code>.
<P>
For example:
<P>
<div class="verbatim"><pre>
PythonOption mod_python.importer.path "['/some/path']"
</pre></div>
<P>
The argument to the option must be in the form of a Python list. The
enclosing quotes are to ensure that Apache interprets the argument as a
single value. The list must be self contained and cannot reference any
prior value of the option. The list MUST NOT reference <code>sys.path</code>
nor should any directory which also appears in <code>sys.path</code> be
listed in the mod_python module importer search path.
<P>
When searching for the module, a check is made for any code file with the
name specified and having a '.py' extension. Because only modules
implemented as a single file will be found, packages will not be found
nor modules contained within a package.
<P>
In any case where a module cannot be found, control is handed off to the
standard Python module importer which will attempt to find the module or
package by searching <code>sys.path</code>.
<P>
Note that only modules found by the mod_python module importer are
candidates for automatic module reloading. That is, where the mod_python
module importer could not find a module and handed the search off to the
standard Python module importer, those modules or packages will not be
able to be reloaded.
<P>
Although true Python packages are not candidates for reloading and must
be located in a directory listed in <code>sys.path</code>, another form of
packaging up modules such that they can be maintained within their own
namespace is supported. When this mechanism is used, these modules will
be candidates for reloading when found by the mod_python module importer.
<P>
In this scheme for maintaining a pseudo package, individual modules are
still placed into a directory, but the <code>__init__.py</code> file in the
directory has no special meaning and will not be automatically imported
as is the case with true Python packages. Instead, any module within the
directory must always be explicitly identified when performing an import.
<P>
To import a named module contained within these pseudo packages, rather
than using a '.' to distinguish a sub module from the parent, a '/' is
used instead. For example:
<P>
<div class="verbatim"><pre>
from mod_python import apache
module = apache.import_module('dirname/module_name')
</pre></div>
<P>
If an <code>__init__.py</code> file is present and it was necessary to import
it to achieve the same result as importing the root of a true Python
package, then <code>__init__</code> can be used as the module name. For example:
<P>
<div class="verbatim"><pre>
from mod_python import apache
module = apache.import_module('dirname/__init__')
</pre></div>
<P>
As a true Python package is not being used, if a module in the directory
needs to refer to another module in the same directory, it should use
just its name, it should not use any form of dotted path name via the
root of the package as would be the case for true Python packages.
Modules in subdirectories can be imported by using a '/' separated path
where the first part of the path is the name of the subdirectory.
<P>
As a new feature in mod_python 3.3, when using the standard Python
'import' statement to import a module, if the import is being done from a
module which was previously imported by the mod_python module importer,
it is equivalent to having called <code>apache.import_module()</code> directly.
<P>
For example:
<P>
<div class="verbatim"><pre>
import name
</pre></div>
<P>
is equivalent to:
<P>
<div class="verbatim"><pre>
from mod_python import apache
name = apache.import_module('name')
</pre></div>
<P>
It is also possible to use constructs such as:
<P>
<div class="verbatim"><pre>
import name as module
</pre></div>
<P>
and:
<P>
<div class="verbatim"><pre>
from name import value
</pre></div>
<P>
Although the 'import' statement is used, that it maps through to the
<code>apache.import_module()</code> function ensures that parent/child
relationships are maintained correctly and reloading of a parent will
still work when only the child has been changed. It also ensures that one
will not end up with modules which were separately imported by the
mod_python module importer and the standard Python module importer.
<P>
With the reimplementation of the module importer in mod_python 3.3, the
<var>module_name</var> argument may also now be an absolute path name of an
actual Python module contained in a single file. On Windows, a drive
letter can be supplied if necessary. For example:
<P>
<div class="verbatim"><pre>
from mod_python import apache
name = apache.import_module('/some/path/name.py')
</pre></div>
<P>
or:
<P>
<div class="verbatim"><pre>
from mod_python import apache
import os
here = os.path.dirname(__file__)
path = os.path.join(here, 'module.py')
module = apache.import_module(path)
</pre></div>
<P>
Where the file has an extension, that extension must be supplied. Although
it is recommended that code files still make use of the '.py' extension,
it is not actually a requirement and an alternate extension can be used.
For example:
<P>
<div class="verbatim"><pre>
from mod_python import apache
import os
here = os.path.dirname(__file__)
path = os.path.join(here, 'servlet.mps')
servlet = apache.import_module(path)
</pre></div>
<P>
To avoid the need to use hard coded absolute path names to modules, a few
shortcuts are provided. The first of these allow for the use of relative
path names with respect to the directory the module performing the
import is located within.
<P>
For example:
<P>
<div class="verbatim"><pre>
from mod_python import apache
parent = apache.import_module('../module.py')
subdir = apache.import_module('./subdir/module.py')
</pre></div>
<P>
Forward slashes must always be used for the prefixes './' and '../', even
on Windows hosts where native pathname use a backslash. This convention
of using forward slashes is used as that is what Apache normalizes all
paths to internally. If you are using Windows and have been using
backward slashes with <code>Directory</code> directives etc, you are using
Apache contrary to what is the accepted norm.
<P>
A further shortcut allows paths to be declared relative to what is
regarded as the handler root directory. The handler root directory is the
directory context in which the active <code>Python*Handler</code> directive was
specified. If the directive was specified within a <code>Location</code> or
<code>VirtualHost</code> directive, or at global server scope, the handler root
will be the relevant document root for the server.
<P>
To express paths relative to the handler root, the '~/' prefix
should be used. A forward slash must again always be used, even on Windows.
<P>
For example:
<P>
<div class="verbatim"><pre>
from mod_python import apache
parent = apache.import_module('~/../module.py')
subdir = apache.import_module('~/subdir/module.py')
</pre></div>
<P>
In all cases where a path to the actual code file for a module is given,
the <var>path</var> argument is redundant as there is no need to search
through a list of directories to find the module. In these situations,
the <var>path</var> is instead taken to be a list of directories to use as the
initial value of the <code>__mp_path__</code> variable contained in the
imported modules instead of an empty path.
<P>
This feature can be used to attach a more restrictive search path to a
set of modules rather than using the <code>PythonOption</code> to set a global
search path. To do this, the modules should always be imported through a
specific parent module. That module should then always import submodules
using paths and supply <code>__mp_path__</code> as the <var>path</var> argument to
subsequent calls to <code>apache.import_module()</code> within that module. For
example:
<P>
<div class="verbatim"><pre>
from mod_python import apache
module1 = apache.import_module('./module1.py', path=__mp_path__)
module2 = apache.import_module('./module2.py', path=__mp_path__)
</pre></div>
<P>
with the module being imported as:
<P>
<div class="verbatim"><pre>
from mod_python import apache
parent = apache.import_module('~/modules/parent.py', path=['/some/path'])
</pre></div>
<P>
The parent module may if required extend the value of <code>__mp_path__</code>
prior to using it. Any such directories will be added to those inherited
via the <var>path</var> argument. For example:
<P>
<div class="verbatim"><pre>
from mod_python import apache
import os
here = os.path.dirname(__file__)
subdir = os.path.join(here, 'subdir')
__mp_path__.append(subdir)
module1 = apache.import_module('./module1.py', path=__mp_path__)
module2 = apache.import_module('./module2.py', path=__mp_path__)
</pre></div>
<P>
In all cases where a search path is being specified which is specific
to the mod_python module importer, whether it be specified using the
<code>PythonOption</code> called <code>mod_python.importer.path</code>, using the
<var>path</var> argument to the <code>apache.import_module()</code> function or
in the <code>__mp_path__</code> attribute, the prefix '~/'
can be used in a path and that path will be taken as being relative
to handler root. For example:
<P>
<div class="verbatim"><pre>
PythonOption mod_python.importer.path "['~/modules']"
</pre></div>
<P>
If wishing to refer to the handler root directory itself, then
'~' can be used and the trailing slash left off. For example:
<P>
<div class="verbatim"><pre>
PythonOption mod_python.importer.path "['~']"
</pre></div>
<P>
Note that with the new module importer, as directories associated with
<code>Python*Handler</code> directives are no longer being added automatically
to <code>sys.path</code> and they are instead used directly by the module
importer only when required, some existing code which expected to be able
to import modules in the handler root directory from a module in a
subdirectory may no longer work. In these situations it will be necessary
to set the mod_python module importer path to include '~'
or list '~' in the <code>__mp_path__</code> attribute of the module
performing the import.
<P>
This trick of listing '~' in the module importer path
will not however help in the case where Python packages were previously
being placed into the handler root directory. In this case, the Python
package should either be moved out of the document tree and the directory
where it is located listed against the <code>PythonPath</code> directive, or the
package converted into the pseudo packages that mod_python supports and
change the module imports used to access the package.
<P>
Only modules which could be imported by the mod_python module importer
will be candidates for automatic reloading when changes are made to the
code file on disk. Any modules or packages which were located in a
directory listed in <code>sys.path</code> and which were imported using the
standard Python module importer will not be candidates for reloading.
<P>
Even where modules are candidates for module reloading, unless a true
value was explicitly supplied as the <var>autoreload</var> option to the
<code>apache.import_module()</code> function they will only be reloaded if the
<code>PythonAutoReload</code> directive is <code>On</code>. The default value when
the directive is not specified will be <code>On</code>, so the directive need
only be used when wishing to set it to <code>Off</code> to disable automatic
reloading, such as in a production system.
<P>
Where possible, the <code>PythonAutoReload</code> directive should only be
specified in one place and in the root context for a specific Python
interpreter instance. If the <code>PythonAutoReload</code> directive is used in
multiple places with different values, or doesn't cover all directories
pertaining to a specific Python interpreter instance, then problems can
result. This is because requests against some URLs may result in modules
being reloaded whereas others may not, even when through each URL the
same module may be imported from a common location.
<P>
If absolute certainty is required that module reloading is disabled and
that it isn't being enabled through some subset of URLs, the
<code>PythonImport</code> directive should be used to import a special module
whenever an Apache child process is being created. This module should
include a call to the <code>apache.freeze_modules()</code> function. This
will have the effect of permanently disabling module reloading for the
complete life of that Apache child process, irrespective of what value
the <code>PythonAutoReload</code> directive is set to.
<P>
Using the new ability within mod_python 3.3 to have <code>PythonImport</code>
call a specific function within a module after it has been imported,
one could actually dispense with creating a module and instead call
the function directory out of the <code>mod_python.apache</code> module.
For example:
<P>
<div class="verbatim"><pre>
PythonImport mod_python.apache::freeze_modules interpreter_name
</pre></div>
<P>
Where module reloading is being undertaken, unlike the core module
importer in versions of mod_python prior to 3.3, they are not reloaded on
top of existing modules, but into a completely new module instance. This
means that any code that previously relied on state information or data
caches to be preserved across reloads will no longer work.
<P>
If it is necessary to transfer such information from an old module to the
new module, it is necessary to provide a hook function within modules to
transfer across the data that must be preserved. The name of this hook
function is <code>__mp_clone__()</code>. The argument given to the hook
function will be an empty module into which the new module will subsequently
be loaded.
<P>
When called, the hook function should copy any data from the old module
to the new module. In doing this, the code performing the copying should
be cognizant of the fact that within a multithreaded Apache MPM that
other request handlers could still be trying to access and update the
data to be copied. As such, the hook function should ensure that it uses
any thread locking mechanisms within the module as appropriate when
copying the data. Further, it should copy the actual data locks
themselves across to the new module to ensure a clean transition.
<P>
Because copying integral values will result in the data then being
separate, it may be necessary to always store data within a dictionary so
as to provide a level of indirection which will allow the data to be
usable from both module instances while they still exist.
<P>
For example:
<P>
<div class="verbatim"><pre>
import threading, time
if not globals().has_key('_lock'):
# Initial import of this module.
_lock = threading.Lock()
_data1 = { 'value1' : 0, 'value2': 0 }
_data2 = {}
def __mp_clone__(module):
_lock.acquire()
module._lock = _lock
module._data1 = _data1
module._data2 = _data2
_lock.release()
</pre></div>
<P>
Because the old module is about to be discarded, the data which is
transferred should not consist of data objects which are dependent on
code within the old module. Data being copied across to the new module
should consist of standard Python data types, or be instances of classes
contained within modules which themselves are not candidates for
reloading. Otherwise, data should be migrated by transforming it into
some neutral intermediate state, with the new module transforming it back
when its code executes at the time of being imported.
<P>
If these guidelines aren't heeded and data is dependent on code objects
within the old module, it will prevent those code objects from being
unloaded and if this continues across multiple reloads, then process size
may increase over time due to old code objects being retained.
<P>
In any case, if for some reason the hook function fails and an exception
is raised then both the old and new modules will be discarded. As a last
opportunity to release any resources when this occurs, an extra hook
function called <code>__mp_purge__()</code> can be supplied. This function will
be called with no arguments.
<P>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-33' xml:id='l2h-33' class="function">allow_methods</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>*args</var><big>]</big><var></var>)</td></tr></table></dt>
<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:
<div class="verbatim"><pre>
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></div>
<P>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-34' xml:id='l2h-34' class="function">exists_config_define</tt></b>(</nobr></td>
<td><var>name</var>)</td></tr></table></dt>
<dd>
This function returns True if the Apache server was launched
with the definition with the given <var>name</var>. This means
that you can test whether Apache was launched with the <code>-DFOOBAR</code>
parameter by calling <code>apache.exists_config_define('FOOBAR')</code>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-35' xml:id='l2h-35' class="function">stat</tt></b>(</nobr></td>
<td><var>fname, wanted</var>)</td></tr></table></dt>
<dd>
This function returns an instance of an <code>mp_finfo</code> object
describing information related to the file with name <code>fname</code>.
The <code>wanted</code> argument describes the minimum attributes which
should be filled out. The resultant object can be assigned to the
<code>req.finfo</code> attribute.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-36' xml:id='l2h-36' class="function">register_cleanup</tt></b>(</nobr></td>
<td><var>callable</var><big>[</big><var>, data</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Registers a cleanup that will be performed at child shutdown time. Equivalent
to <tt class="function">server.register_cleanup()</tt>, except that a request object is not
required.
<em>Warning:</em> do not pass directly or indirectly a request object in the
data parameter. Since the callable will be called at server shutdown time,
the request object won't exist anymore and any manipulation of it in the
handler will give undefined behaviour.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-37' xml:id='l2h-37' class="function">config_tree</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns the server-level configuration tree. This tree does not
include directives from .htaccess files. This is a <em>copy</em> of
the tree, modifying it has no effect on the actual configuration.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-38' xml:id='l2h-38' class="function">server_root</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Returns the value of ServerRoot.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-39' xml:id='l2h-39' class="function">make_table</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
This function is obsolete and is an alias to <tt class="class">table</tt> (see below).
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-40' xml:id='l2h-40' class="function">mpm_query</tt></b>(</nobr></td>
<td><var>code</var>)</td></tr></table></dt>
<dd>
Allows querying of the MPM for various parameters such as numbers of
processes and threads. The return value is one of three constants:
<div class="verbatim"><pre>
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></div>
<P>
The <var>code</var> argument must be one of the following:
<div class="verbatim"><pre>
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></div>
<P>
Example:
<div class="verbatim"><pre>
if apache.mpm_query(apache.AP_MPMQ_IS_THREADED):
# do something
else:
# do something else
</pre></div>
</dl>
<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="4.5 apache - Access"
href="module-apache.html"><img src='previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="4.5 apache - Access"
href="module-apache.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="4.5.2 Attributes"
href="pyapi-apmem.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="module-apache.html">4.5 apache - Access</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-apache.html">4.5 apache - Access</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="pyapi-apmem.html">4.5.2 Attributes</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>
|