[mod_python] I want mod_python to execute .pyc (or .pyo) files only

Graham Dumpleton graham.dumpleton at gmail.com
Thu Oct 18 06:41:25 EDT 2007


Cannot be done if using mod_python.publisher, or where the handler
code file is in the document tree and a candidate for module
reloading. This  is because the mod_python module importer only uses
.py files and ignores .pyc/.pyo files.

Only time it would work is for a top level handler specified by
PythonHandler which is somewhere on sys.path and not the mod_python
module search locations.

Graham

On 18/10/2007, apocalypznow <apocalypznow at gmail.com> wrote:
> Hello,
>
> Is there a way I can cause mod_python to execute only pyc (or pyo)
> files?  I have removed the .py files after manually compiling (using
> py_compile).  The file I want to execute is listed:
>
> -rwxr-xr-x 1 root root 374 2007-09-17 23:20 index.pyc
>
> My httpd.conf has the following:
> Alias /test2 "/var/www/mod_python/test2"
> <Directory /var/www/mod_python/test2>
>    AddHandler python-program .pyc
>    Options -MultiViews -Indexes
>    PythonHandler mod_python.publisher
>    PythonPath 'sys.path'
>    PythonDebug On
> </Directory>
>
> The index.py (which was removed) contains the following:
> def index(req):
>          return "Index hit."
> def hello(req):
>          return "Hello hit."
>
> When I execute http://some.url/test2/hello , I get the following:
> The requested URL /test2/hello was not found on this server.
>
> I am running mod_python 3.2.8 and Python2.3.5 on Apache 2.
>
> The reason I want to do this is to put a small obstacle to my client
> from easily seeing the source code.  I realise this can be decompiled
> but decompilation does not produce nice results to work from, hence it
> is enough of an obstacle.  I wish to protect my authoring rights through
>   this.
>
> Can someone please help?
>
> _______________________________________________
> 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