[mod_python] ImportError: No module named index

Robert Geller robert at worksofmagic.com
Thu Oct 21 21:22:39 EDT 2004


Hello all --
 
I have encountered a dilemma. I do not want to specifically use the .py
extension for my mod-python files, and for understandable reasons.
In httpd.conf, I put 
 

<Directory /usr/local/apache2/htdocs/python>
AddHandler python-program .n
PythonHandler index::index
PythonDebug On
</Directory>

I even specified "index.n" under PythonHandler, i.e. "PythonHandler
index.n::index". Note *.n is the extension I want to use at the moment,
for test purposes.
 
Well, when I make a file named "index.n" with the handler function
"index", with the following code:
 
from mod_python import apache
 
def index(req):
 
        req.content_type = "text/html"
        req.send_http_header()
        req.write("Welcome to Robert's page!")
 
        return apache.OK
 
It returns the following error:
 
Mod_python error: "PythonHandler index.n::index"



Traceback (most recent call last):



  File
"/usr/local/python/lib/python2.4/site-packages/mod_python/apache.py",
line 287, in HandlerDispatch

    log=debug)



  File
"/usr/local/python/lib/python2.4/site-packages/mod_python/apache.py",
line 454, in import_module

    f, p, d = imp.find_module(parts[i], path)



ImportError: No module named index
 
Oddly, when I make the handler file, or module, "index.py", it works!
But I don't *want* to make any related file have the
*.py extension, even if it's just the handler. I realize I can use
index.py for the handler and then *.n for the front-end files,
but that's not how I want to do things.
 
If anybody could please advise me on making actual *handlers* without
.py extensions, that would be great! 
 
Regards.
 
 
 

Robert Geller

robert at worksofmagic.com

 

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20041021/850e69fb/attachment.html


More information about the Mod_python mailing list