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

Graham Dumpleton grahamd at dscpl.com.au
Wed Aug 25 13:20:03 EDT 2004


On 24/08/2004, at 9:54 AM, Gregory (Grisha) Trubetskoy wrote:

>
> 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")

No time right now for an extended description, will send one later, but 
Vampire which I
described recently and which is available at 
"http://www.dscpl.com.au/projects/vampire"
has a module caching system which has explicit module importing similar 
to the
mod_python.apache module, but what it will do is track relationships 
between module
imports and is able to do a reload even when child imports are changed 
and not the
immediate module you are loading.

What this means is if that A imports B which imports C and similarly D 
imports C, if C
is then changed, all the modules which depend on C, ie., A, B and D 
will be automatically
reloaded when requested, rather than them being grabbed from the cache. 
If all your
application modules are in one place and you always use the module 
importer in Vampire
for importing any application module from a page, but also one 
application module from
another, any change to an application module should see anything that 
depends on it
automatically reloaded.

BTW, various problems I have seen with things appearing not to be 
reimported correctly
are actually because of intermediate proxy servers caching stuff. Thus 
need to explicitly
say not to cache stuff in response, although error pages can stuff that 
up also.



--
Graham Dumpleton (grahamd at dscpl.com.au)



More information about the Mod_python mailing list