Issue Details (XML | Word | Printable)

Key: MODPYTHON-55
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Nicolas Lehuen
Reporter: Nicolas Lehuen
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

Add a version attribute to the mod_python module.

Created: 19/May/05 10:35 PM   Updated: 05/Mar/06 03:09 PM
Component/s: None
Affects Version/s: 3.1.4
Fix Version/s: 3.2.7

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works serverobject.c-jg20050531-1.diff 2005-06-01 12:09 AM Jim Gallacher 1 kB

Resolution Date: 19/May/05 11:06 PM


 Description  « Hide
(asked by dharana) There is no easy way to know the version of mod_python used from within an handler. Why not try to add a version string attribute to the mod_python module ?

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Nicolas Lehuen added a comment - 19/May/05 11:06 PM
Solved by adding an hand-rolled version attribute to mod_python/__init__.py.

We should find a way to automate the generation of this value from src/include/mpversion.h at build time.

Jim Gallacher added a comment - 21/May/05 12:44 AM
Would it be appropriate to determine the version at configure time?

If so we could create a file mod_python/__init__.py.in which would contain:
version="@MP_VERSION@"

and configure would grep src/include/mpversion.h for MPV_STRING and generate __init__.py from __init__.py.in.

If this seems reasonable I can put something together.

David Fraser added a comment - 31/May/05 10:18 PM
Seems reasonable ; it would be nice to retain the ability to build without configure by running setup.py directly (at least on Windows)
Note that setup.py.in already contains a getmp_version() method that reads the version out of src/include/mpversion.h

Jim Gallacher added a comment - 01/Jun/05 12:09 AM
On further consideration, lets bypass the whole config issue and add a method to serverobject.c:

static PyObject * server_get_mp_version(serverobject *self)
{
    PyObject *version;
    version = PyString_FromString(MPV_STRING);
    if (!version)
        return NULL;

    Py_INCREF(version);
    return version;
    
}

Usage: req.server.get_mp_version()

Jim Gallacher added a comment - 01/Jun/05 12:38 AM
I think I messed up the referernce counting in the code for server_get_mp_version. I'm new at this and the Python documentation is just plain confusing. I *think* the correct code is:

static PyObject * server_get_mp_version(serverobject *self)
{
    
    return PyString_FromString(MPV_STRING);
        
}

If someone can confirm this I'll attach a corrected patch.

Graham Dumpleton added a comment - 05/Mar/06 03:09 PM
Closing issue because "version" attribute was added to "mod_python/__init__.py". I note though that no "req.server.get_mp_string()" function seems to have added in the end as described.