You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-commits@quetz.apache.org by gr...@apache.org on 2002/09/19 22:11:35 UTC

cvs commit: httpd-python/lib/python/mod_python apache.py

grisha      2002/09/19 13:11:35

  Modified:    src      _apachemodule.c util.c
               src/include util.h
               Doc      modpython4.tex
               lib/python/mod_python apache.py
  Log:
  Added apache.config_tree() and apache.server_root().
  
  Revision  Changes    Path
  1.18      +24 -1     httpd-python/src/_apachemodule.c
  
  Index: _apachemodule.c
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/_apachemodule.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- _apachemodule.c	12 Sep 2002 18:24:06 -0000	1.17
  +++ _apachemodule.c	19 Sep 2002 20:11:35 -0000	1.18
  @@ -352,12 +352,35 @@
       return pairs;
   }
   
  +/**
  + ** config_tree
  + **
  + *   Returns a copy of the config tree
  + */
  +
  +static PyObject *config_tree()
  +{
  +    return cfgtree_walk(ap_conftree);
  +}
  +
  +/**
  + ** server_root
  + **
  + *   Returns ServerRoot
  + */
  +
  +static PyObject *server_root()
  +{
  +    return PyString_FromString(ap_server_root);
  +}
   
   /* methods of _apache */
   struct PyMethodDef _apache_module_methods[] = {
       {"log_error",                 (PyCFunction)mp_log_error,     METH_VARARGS},
       {"parse_qs",                  (PyCFunction)parse_qs,         METH_VARARGS},
       {"parse_qsl",                 (PyCFunction)parse_qsl,        METH_VARARGS},
  +    {"config_tree",               (PyCFunction)config_tree,      METH_NOARGS},
  +    {"server_root",               (PyCFunction)server_root,      METH_NOARGS},
       {NULL, NULL} /* sentinel */
   };
   
  
  
  
  1.11      +40 -1     httpd-python/src/util.c
  
  Index: util.c
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/util.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- util.c	15 Sep 2002 23:45:35 -0000	1.10
  +++ util.c	19 Sep 2002 20:11:35 -0000	1.11
  @@ -401,6 +401,7 @@
    ** 
    *   Find a memberdef in a PyMemberDef array
    */
  +
   PyMemberDef *find_memberdef(const PyMemberDef *mlist, const char *name)
   {
       const PyMemberDef *md;
  @@ -411,5 +412,43 @@
   
       /* this should never happen or the mlist is screwed up */
       return NULL;
  +}
  +
  +/**
  + ** cfgtree_walk
  + **
  + *  walks ap_directive_t tree returning a list of
  + *  tuples and lists
  + */
  +
  +PyObject *cfgtree_walk(ap_directive_t *dir)
  +{
  +
  +    PyObject *list = PyList_New(0);
  +    if (!list)
  +        return PyErr_NoMemory();
  +
  +    while (dir) {
  +
  +        PyObject *t = Py_BuildValue("(s, s)", dir->directive, dir->args);
  +        if (!t)
  +            return PyErr_NoMemory();
  +
  +        PyList_Append(list, t);
  +
  +        if (dir->first_child) {
  +
  +            PyObject *child = cfgtree_walk(dir->first_child);
  +            if (!child)
  +                return PyErr_NoMemory();
  +
  +            PyList_Append(list, child);
  +
  +        }
  +
  +        dir = dir->next;
  +    } 
  +
  +    return list;
   }
   
  
  
  
  1.8       +2 -1      httpd-python/src/include/util.h
  
  Index: util.h
  ===================================================================
  RCS file: /home/cvs/httpd-python/src/include/util.h,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- util.h	15 Sep 2002 23:45:35 -0000	1.7
  +++ util.h	19 Sep 2002 20:11:35 -0000	1.8
  @@ -74,5 +74,6 @@
   char * get_addhandler_extensions(request_rec *req);
   apr_status_t python_decref(void *object);
   PyMemberDef *find_memberdef(const PyMemberDef *mlist, const char *name);
  +PyObject *cfgtree_walk(ap_directive_t *dir);
   
   #endif /* !Mp_UTIL_H */
  
  
  
  1.24      +13 -2     httpd-python/Doc/modpython4.tex
  
  Index: modpython4.tex
  ===================================================================
  RCS file: /home/cvs/httpd-python/Doc/modpython4.tex,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- modpython4.tex	18 Sep 2002 19:29:44 -0000	1.23
  +++ modpython4.tex	19 Sep 2002 20:11:35 -0000	1.24
  @@ -291,10 +291,12 @@
   from mod_python import apache
   \end{verbatim}
   
  -\module{mod_python.apache} module defines the following objects and
  -functions. For a more in-depth look at Apache internals, see the
  +\module{mod_python.apache} module defines the following functions and
  +objects. For a more in-depth look at Apache internals, see the
   \citetitle[http://httpd.apache.org/dev/]{Apache Developer page}
   
  +\subsection{Functions\label{pyapi-apmeth}}
  +
   \begin{funcdesc}{log_error}{message\optional{, level, server}}
   An interface to the Apache
   \citetitle[http://dev.apache.org/apidoc/apidoc_ap_log_error.html]{ap_log_error()}
  @@ -360,6 +362,15 @@
   M_INVALID
   \end{verbatim}
   
  +\end{funcdesc}
  +
  +\begin{funcdesc}{config_tree}{}
  +Returns the server-level configuration tree. This tree does not
  +include directives from .htaccess files.
  +\end{funcdesc}
  +
  +\begin{funcdesc}{server_root}{}
  +Returns the value of ServerRoot.
   \end{funcdesc}
   
   \begin{funcdesc}{make_table}{} 
  
  
  
  1.59      +2 -0      httpd-python/lib/python/mod_python/apache.py
  
  Index: apache.py
  ===================================================================
  RCS file: /home/cvs/httpd-python/lib/python/mod_python/apache.py,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- apache.py	17 Sep 2002 03:37:23 -0000	1.58
  +++ apache.py	19 Sep 2002 20:11:35 -0000	1.59
  @@ -777,6 +777,8 @@
   make_table = _apache.table
   log_error = _apache.log_error
   table = _apache.table
  +config_tree = _apache.config_tree
  +server_root = _apache.server_root
   
   ## Some constants