Closed rafdre closed 7 years ago
issue is not related to weapp2 but to WSGI and the path where python search for files. Most simple solution is to add something like this ; execfile("/srv/http/test.py") it will import the file.
other than this here is quite good article http://blog.dscpl.com.au/2014/09/python-module-search-path-and-modwsgi.html
I am testing Google Cloud and first I wanted to develop something on my PC before I use in on google cloud. I am using APACHE and configured it in that way, that when I am going to the page localhost/wsgi_app I see my page which physically is stored in folder /svc/http/webapp2. File wsgi_app.py which contains my app is stored in subfolder webapp2. All works fine. I provide this information just in case it might play any role. The issue I have is with import from library. I did it on Django and now try to move it to webapp2. The first lines of my program look like this:
I have file called test.py which contains some classes and functions. it is in the same folder as wsgi_app.py. I want to include it, however this seems not to work:
my test.py contains definition of the class 'Quote', but when I call the page I see error
NameError: global name 'Quote' is not defined
When I put the inside of the file test.py in the file wsgi_app.py all works fine. My goal is to separate the code into several files.
Is this a bug or I am doing something completely wrong? why 'from test import *' does not work as for any other cases ?