[mod_python] How can I turn off apparent caching of python code?

Gregory (Grisha) Trubetskoy grisha at modpython.org
Mon Aug 23 20:54:08 EDT 2004


On Mon, 23 Aug 2004, Tobiah wrote:

>
>>  DEBUG = 1
>> 
>>  import mymodulea
>>  import mymoduleb
>> 
>>  if DEBUG:
>>         mymodulea = reload(mymodulea)
>>         mymoduleb = reload(mymoduleb)
>> 
>> 
>> That is O.K., but still, unwieldy.

This method is pretty old, now a simpler way to do it is:

mymodulea = apache.import_module("mymodulea")
mymoduleb = apache.import_module("mymoduleb")

This will obey the PythonAutoReload setting. Note that it still uses 
reload() under the hood.

> What's more it does not always work.  The docs on
> the reload() function reveal that many of the changes
> that I make to a module will not have any effect.
>
> If I change the name of a class for instance, the
> old one still exists until the apache server is restarted.
>
> So, is there any way at all that I can avoid caching python
> objects entirely while developing?

No, not without altering how Python works, which is way outside the scope 
of mod_python.

Grisha


More information about the Mod_python mailing list