[mod_python] PyhtonImport

Graham Dumpleton grahamd at dscpl.com.au
Fri Oct 14 18:06:25 EDT 2005


PythonImport can't be used inside a Directory directive, must be
outside of it. This is because it is being evaluated at startup and
not when a request mapping to a specific directory is received.
Thus structure it as:

<VirtualHost ...>

   PythonImport ...

   <Directory ...>
   </Directory>

</virtualHost>

If that still doesn't work, put it outside of VirtualHost. Not sure if
that is required or not.

Graham

On 15/10/2005, at 3:52 AM, Alexis Marrero wrote:

> I tried that same statement and got, PythonImport not allowed here.
>
> Syntax error on line 1114 of /Users/amarrero/djp/server/conf/amarre- 
> httpd.conf:
> PythonImport not allowed here
>
> This is the httpd.conf:
>
> <VirtualHost core.mitre.org:1973>
>
>     Alias / "/Users/amarrero/djp/server/webapp/"
>
>     <Directory "/Users/amarrero/djp/server/webapp/">
>
>       SetHandler python-program
>       PythonHandler index
>       PythonPath "sys.path + ['/Users/amarrero/djp/server/webapp/']"
>       PythonDebug On
>
>       PythonImport server.startup doublecore.mitre.org
>
>     </Directory>
> </VirtualHost>
>
>
> Am I missing something in the conf?
>
> /amn
>
> On Oct 14, 2005, at 1:41 PM, Paul Hide wrote:
>
>
>> Server is: Apache 2.0.54, mod_python 3.1.3 Debian 3.1
>> Client is Firefox 1.0.7 on ms win 2k
>> The following file is successfully imported by a PythonImport  
>> directive.
>>
>>     #PythonImport test
>>
>>     from mod_python import apache
>>
>>     apache.log_error('q8 q8 q8 q8')
>>
>> I know this because it writes to the error log.
>>
>> The directive that loads it is:
>>
>>     PythonImport pyimp localhost.localdomain
>>
>> I know that my publisher programs are being run in this  
>> interpreter because:
>>
>>     def t(req):
>>         return str(req.interpreter) #probably is a string anyway
>>
>> returns localhost.localdomain into my browser.
>>
>> If I now change my publisher program to say:
>>
>>     def t(req):
>>         return str(globals()) #probably is a string anyway
>>
>> then why can't I see any reference to pyimp in the resulting output?
>>
>>
>> Paul Hide
>> _______________________________________________
>> Mod_python mailing list
>> Mod_python at modpython.org
>> http://mailman.modpython.org/mailman/listinfo/mod_python
>>
>>
>
> _______________________________________________
> 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