Graham Dumpleton
graham.dumpleton at gmail.com
Thu Mar 8 16:05:04 EST 2007
On 09/03/07, Tobin Cataldo <tcataldo at bham.lib.al.us> wrote: > Greetings, > > I would like to ship only .pyo files to a website and use those with > mod_python. I have seen this question in the archives but haven't seen a > clear answer. > > I believe the Python Interpreter will choose a .pyc or .pyo file if > available, but I want to only have the .pyo files in my target directory. > > Apache conf: > DirectoryIndex index.pyo index.py ... > ... > AddHander mod_python .pyo > ... > SetHandler mod_python > > This Apache configuration still requires .py in the target directory or > the page can't be found. > > I am applying mod_python against a directory which Graham says will > translate to a request against index.py > (http://www.dscpl.com.au/wiki/ModPython/Articles/SetHandlerVersusAddHandler). > > How do I overwrite this behavior? I suppose I could do it via Location > directives, but how to do this with DirectoryIndex and the Directory > directives? For code files which are managed by the mod_python module importer you cannot do that as it doesn't use .pyc or .pyo files nor generate them. This has been the case for mod_python.publisher since mod_python 3.2.7 and for all module imports managed by mod_python since 3.3.1. Note that where a module import cannot be done by mod_python and it defers to the standard Python module importer, the standard Python module importer will still make use of .pyc/.pyo files if they exist, although, for .pyo files you would need to have specified the directive: PythonOptimize On Graham
|