Ortal Blumenfeld Lagziel
Ortal Blumenfeld Lagziel

Reputation: 2555

Python with mod wsgi cannot nevigate beteween python files

I want that my wsgi.py will get an access to another dbHandling.py file's functions. When I work with pyCharm all I need to do for 1 file will get an access of another class's functions is:

in wsgi.py file:

from dbHandling import dbHandlingclass

and then:

 dbHandlingclass().getEmployeeData()

But when I connecet to wsgi.py from my browser (address: localhost\wsgi) I get an error:

from dbHandling import dbHandlingclass\r [wsgi:error] ImportError: No module named 'dbHandling '\r

Upvotes: 0

Views: 14

Answers (1)

BlackJack
BlackJack

Reputation: 4689

You'll have to add the path to that module to Python's module search path. Something along the lines of:

import os
import sys
sys.path.insert(0, os.path.dirname(__file__))
from dbHandling import dbHandlingclass

The relevant mod_wsgi documentation: https://code.google.com/p/modwsgi/wiki/ApplicationIssues#Application_Working_Directory

Upvotes: 1

Related Questions