[mod_python] PythonImport: Can someone please draw a diagram for this idiot?

Jim Gallacher jg.lists at sympatico.ca
Wed Sep 14 20:04:15 EDT 2005


Jim Gallacher wrote:
> Jim Gallacher wrote:
> 
>> Jorey Bump wrote:
>>
>>> Jorey Bump wrote:
>>>
>>>> jamestmcneill-python at yahoo.co.uk wrote:
>>>>
>>>>> 3) From this I can see that the PythonImport directive doesn't seem 
>>>>> to be
>>>>> working at all (or at least, in any way I expected it to). It does not
>>>>> produce a compiled version of the module specified, 
>>>>
>>>>
>>>>
>>>>
>>>> This is not unusual. The user that apache runs as must have write 
>>>> permissions in the directory in order to produce a .pyc file. I'm 
>>>> not sure what happens under Windows regarding this, but if I want a 
>>>> compiled version of the module under Linux, I compile it ahead of 
>>>> time or change the permissions (rarely).
>>>
>>>
>>>
>>>
>>> Having said that, I just tried using the PythonImport statement, and 
>>> I also see no evidence that it works. I may be using or testing it 
>>> incorrectly, however.
>>
>>
>>
>> Same result here. I'm looking at the source code now and will report 
>> back.
>>
> 
> I think there may be a bug. I know in the past Grisha has discouraged 
> the use of PythonImport and has stated that he would be happy if it went 
> away. Can anyone confirm if they have used it successfully?

In answer to my own in question, PythonImport does work and there is no 
bug. Re-reading the docs reveals this small detail which I and others 
may have overlooked - the context for the directive. PythonImport only 
works in the server config context. Quoting from the apache docs 
(http://httpd.apache.org/docs/2.0/mod/directive-dict.html#Context)

"""
server config
     This means that the directive may be used in the server 
configuration files (e.g., httpd.conf), but not within any <VirtualHost> 
or <Directory> containers. It is not allowed in .htaccess files at all.
"""

I'll update the docs to make this a little more explicit, since it's 
easy to overlook. I know I did. :)

Hope that helps.
Jim



More information about the Mod_python mailing list