[mod_python] strange import behaviour out of the blue

Graham Dumpleton grahamd at dscpl.com.au
Thu Oct 27 03:01:24 EDT 2005


What version of mod_python are you using? You didn't by chance upgrade
your mod_python version lately, for example to 3.2 beta?

Also, are you using mod_python.publisher or are you using your own top
level handler? Are you using module reloading on the module the import
occurs in? This could be explicitly using apache.import_module() or by
virtue of PythonAutoReload defaulting to On or being set explicitly On.

There are a lot of known issues with module loading/reloading in
mod_python. Version 3.2 starts to remedy some of these issues, but
even so those changes are really an interim fix until 3.3 tries to fix
all problems properly in some way.

For some background reading you might check out:

  http://www.dscpl.com.au/articles/modpython-003.html

Graham

Kevin J. Smith wrote ..
> Hi,
> 
> I have been running an app under mod_python for quite some time. In one
> bit
> of the code I do an import of mx.DateTime like so:
> 
> from mx.DateTime import *
> 
> and I later make a call to the function localtime(). I did a restart on
> the
> server a week or so ago and now I am getting an exception being thrown
> saying that localtime doesn't exist! I have tried importing differently,
> directly, calling it directly like mx.DateTime.localtime() but all are
> unsuccessful. I have logged a call to mx.DateTime.__path__ with the
> following result:
> 
> 2005-10-27 02:04:14,347 Domain -1208703296 DEBUG here is the datetime path:
> ['/usr/lib/python2.3/site-packages/mx/DateTime']
> 
> It looks like it is getting the right module, but logging a call to dir(
> mx.DateTime) yields this:
> 
> 2005-10-27 02:04:14,347 Domain -1208703296 DEBUG here is datetime funcs:
> ['DateTime', '__builtins__', '__doc__', '__file__', '__name__'
> , '__path__', 'mxDateTime']
> 
> Where did all the stuff go?!?
> 
> If I go on the command line and do the same I get the same path but the
> following for the dir():
> 
> ['ARPA', 'Age', 'April', 'August', 'Date', 'DateFrom', ... AND MANY, MANY
> OTHERS ... 'localtime', 'mktime', 'mxDateTime', 'mxDateTimeAPI', 'now',
> ...
> etc. etc. ]
> 
> Why is mod_python all of a sudden failing to import the module correctly?
> I
> am really, really stumped because I have been using this app for close
> to
> two years and have never ran into this problem.
> 
> I would be greatful for any insight that anyone can provide as to what
> is
> going on!
> 
> Cheers


More information about the Mod_python mailing list