[mod_python] database connection

Graham Dumpleton grahamd at dscpl.com.au
Sun Oct 16 07:15:50 EDT 2005


On 16/10/2005, at 9:05 PM, Julien Cigar wrote:

>> In other words, that you can specify a '/' like you are is quite 
>> specific
>> to the current mod_python implementation of apache.import_module(). 
>> Well,
>> that is what I thought ......
>>
>> At this point I am a bit confused as I can't find anything in the 
>> mod_python
>> code which would even allow '/' to work. When I even try using it on 
>> my
>> platform, Python throws an exception:
>>
>>   ImportError: No module named pages/page1
>>
>> What version of mod_python are you using, what version of Python and 
>> what
>> platform? I don't understand how it could be working for you.
>>
> I'm using mod_python version 3.1.3 on a Debian Linux platform (kernel 
> 2.6.12) with Python 2.3
> A small piece of my code can be found on 
> http://rafb.net/paste/results/9sjUSi95.html

Interesting. I just got onto a Linux system as well and tried __import__
and it does actually work for '/'. Ie.,

Python 2.3.3 (#1, May  7 2004, 10:31:40)
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> __import__('pages/page1')
hi
<module 'pages/page1' from 'pages/page1.pyc'>
 >>> __import__('pages.page1')
hi
<module 'pages' from 'pages/__init__.pyc'>

Yet the same thing on Mac OS X doesn't work:

Python 2.3 (#1, Sep 13 2003, 00:49:11)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> __import__('pages/page1')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
ImportError: No module named pages/page1
 >>> __import__('pages.page1')
page1
<module 'pages' from 'pages/__init__.pyc'>

Looks like it may work for you on Linux, but doesn't look like it is 
going
to be portable to other platforms.

Will be interesting to see what other platforms do.

Graham



More information about the Mod_python mailing list