Cannot include my own package into wsgi file.

2 views
Skip to first unread message

Миклухо

unread,
Dec 25, 2009, 6:50:08 AM12/25/09
to modwsgi
Hi, all. I have a simple application :
def my_wsgi_application (environ, start_response):
status = '200 OK'
output = 'This is my application'
response_headers = [('Content-type', 'text/plain')]
start_response(status, response_headers)
return [output]
application = my_wsgi_application

which executes ok. I want to import files written by me, but it cannot
find it in path. Can anyone explain what should I do to import not(!)
system files. Searched all the web, no answer is available.

Garito

unread,
Dec 25, 2009, 9:41:58 AM12/25/09
to modwsgi
You need to put your files into de python path in order to import them
or do that:

from os.path import dirname, abspath

path.append(abspath(dirname(__file__)))

It put the folder that contains you file in the python path

Cheers

Graham Dumpleton

unread,
Dec 26, 2009, 4:48:15 AM12/26/09
to mod...@googlegroups.com
2009/12/25 Миклухо <mik...@gmail.com>:

But did you read any of the mod_wsgi documentation. ;-)

Read about WSGIPythonPath if using embedded mode:

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIPythonPath

If using daemon mode read about python-path option to
WSGIDaemonProcess directive:

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess

Also read Python documentation about 'sys.path' variable and module
search paths:

http://docs.python.org/library/sys.html#sys.path

This mechanism can be used to extend the path in the WSGI script file.

For other related information about Python module search paths and
mod_wsgi also read:

http://code.google.com/p/modwsgi/wiki/VirtualEnvironments
http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode#Reloading_In_Embedded_Mode

Graham

Mikluxo Maklai

unread,
Dec 27, 2009, 11:06:45 PM12/27/09
to mod...@googlegroups.com
Thanks! It works :) Sorry for such stupid questions and my poor english.

2009/12/26 Graham Dumpleton <graham.d...@gmail.com>

--

You received this message because you are subscribed to the Google Groups "modwsgi" group.
To post to this group, send email to mod...@googlegroups.com.
To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.



Reply all
Reply to author
Forward
0 new messages