[mod_python] Importing different script with the same names

Michael C. Neel neel at mediapulse.com
Tue Jan 13 10:44:49 EST 2004


I ran into this as well when I was toying with a source code browser.  I
imported the modules and hashed the name against the dir like so:

name = '%s_%s' % (page.split('/')[-1].replace('.py',''),
                  md5.new(fulldir+page).hexdigest())

m = imp.load_module(name,file(fulldir+page),
                    fulldir+page, ('.py', 'r', imp.PY_SOURCE))

HTML = pydoc.HTMLDoc().document(m)

Works fine, but you end up with a lot of modules loaded you are not
using.  I ended up using a method that didn't require an import to get
docstrings.  The virthost is a better way to go if you can.

Mike

--
Michael C. Neel
Mediapulse, Inc. 

> -----Original Message-----
> From: Michael S. Fischer [mailto:michael at dynamine.net] 
> Sent: Monday, January 12, 2004 9:17 PM
> To: mod_python at modpython.org
> Subject: Re: [mod_python] Importing different script with the 
> same names
> 
> 
> Alain Tesio wrote:
> > Hi, I have the problem described in the faq here :
> > 
> > http://www.modpython.org/FAQ/faqw.py?req=show&file=faq03.009.htp
> > 
> > In short, when you request /home/x/script.py and then 
> another requests
> > wants /home/y/script.py the first one is used in the same 
> apache process.
> > 
> > This makes it hard to have production and test scripts on 
> the same machine.
> 
> Alternatively, perhaps you could bind the server to two separate ports
> using <VirtualHost> blocks, each serving the same namespace but using
> different mod_python modules.
> 
> Best,
> 
> --Michael
> 
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python
> 



More information about the Mod_python mailing list