4.3 apache - Access to Apache Internals.
Keywords: modpython

# 4.3 `apache` - Access to Apache Internals.

The Python Application Programmer interface to Apache internals is contained in a module appropriately named `apache`, located inside the `mod_python` package. This module provides some important objects that map to Apache internal structures, as well as some useful functions, all documented below.

The `apache` module can only be imported by a script running under mod_python. This is because it depends on a built-in module `_apache` provided by mod_python. It is best imported like this:

      from mod_python import apache

`mod_python.apache` module defines the following objects and functions. For a more in-depth look at Apache internals, see the Shambhala API Notes

`log_error`(message[, level, server])
  An interface to the Apache ap_log_error() function. message is a string with the error message, level is one of the following constants:

        APLOG_EMERG
        APLOG_ALERT
        APLOG_CRIT
        APLOG_ERR
        APLOG_WARNING
        APLOG_NOTICE
        APLOG_INFO
        APLOG_DEBUG
        APLOG_NOERRNO

  server is a reference to a `Request.server` object. If server 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.

`make_table`()
  Returns a new empty object of type `mp_table`. See Section 4.3.1 for a description of a table object.

Subsections

- 4.3.1 Table Object (mp_table)
- 4.3.2 Request Object
  - 4.3.2.1 Request Methods
  - 4.3.2.2 Request Members
- 4.3.3 Connection Object (mp_conn)
  - 4.3.3.1 Connection Members
- 4.3.4 Server Object (mp_server)
  - 4.3.4.1 Server Methods
  - 4.3.4.2 Server Members
- 4.3.5 Debugging
- 4.3.6 Internal Callback Object