Hi,

I'd like to add my code to python's path variable so I can do import statements. From what I understand, in daemon mode I can tell mod_wsgi where my code is using the python-path option, a bit like this:

WSGIDaemonProcess testtest.elasticmind.net processes=1 threads=5 \
                display-name=test python-path=/home
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / /home/webtest/webtest.wsgi

All the code is world readable and my test directory structure looks like this:

/home/webtest
/home/webtest/__init__.py
/home/webtest/mytest.py
/home/webtest/webtest.wsgi

__init__.py is empty and mytest.py & webtest.wsgi contain the following...


--- mytest.py ---
def hello_world(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'
    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)
    return [output]


--- webtest.wsgi ---
from webtest.mytest import hello_world
application = hello_world()


What from I understand (when I did this with mod_python), the presence of an __init__.py file should make the 'webtest' directory be treated as a module, so this should work; but unfortunately after trying several different things, I seem to still be getting an error like this:

[error] Target WSGI script '/home/webtest/webtest.wsgi' cannot be loaded as Python module. [error] Exception occurred processing WSGI script '/home/webtest/webtest.wsgi'.
[error]  Traceback (most recent call last):
[error]    File "/home/webtest/webtest.wsgi", line 1, in <module>
[error]      from webtest.mytest import hello_world
[error]  ImportError: No module named webtest.mytest


I must be doing something wrong, but I think my brain is beginning to turn into sludge from being ill and doing lots of coding/testing lately. It would be great to get this solved for peace of mind. If anyone could please point out where I'm going wrong, it would be greatly appreciated. Thank you in advance for your time and consideration.
-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.


Reply via email to