[mod_python] How to get mod_python's running version?

Graham Dumpleton grahamd at dscpl.com.au
Thu May 19 05:59:17 EDT 2005


On 19/05/2005, at 7:50 PM, dharana wrote:

> Trying to do a "import mod_python" from an external script works so I 
> should ask, wouldn't it nice to have a mod_python.version string with 
> just the current version or isn't it a good idea?

No harm in having it. Most Python packages do.

> The problem is I want to make sure if it's 3.2 or later (FileSession, 
> php.parsestring bugfix et all) in the script so I can't use the hacks 
> available on testhandler or vampire because I believe they don't 
> differentiate that.

One of the good things about Python is that you can do checks like:

   try:
     from mod_python import psp
   except:
     # Don't have PSP.

and:

   from mod_python import Session
   if hasattr(Session,"FileSession"):
     # Have FileSession.

I know this doesn't in general help with knowing whether a bug fix is 
present
as that may be harder to test for, but can be used to test for certain 
features
by virtue of presence of a module or of an attribute in a module.

Graham



More information about the Mod_python mailing list