Setting custom django.wsgi entries

Repository of web frameworks and applications for Microsoft IIS.
User avatar
Posts: 56
Joined: 01 Nov 2013, 01:50

Setting custom django.wsgi entries

07 Nov 2013, 11:40

Hi,

Our app requires the following entries setup in django.wsgi:

PROJECT_ROOT = os.path.dirname(__file__)
INNER_ROOT = os.path.join(PROJECT_ROOT, 'app')

sys.path.insert(0, PROJECT_ROOT)
sys.path.insert(1, INNER_ROOT)

Any idea where to insert them in Helicon Zoo?

Thanks!

User avatar
Posts: 110
Joined: 07 Mar 2012, 10:22

Re: Setting custom django.wsgi entries

08 Nov 2013, 06:40

Hello!

There is a two ways to update PYTHONPATH:

1. Update PYTHONPATH environment variable in heliconZoo/application/environmentVariables section of web.config. Use %APPL_PHYSICAL_PATH% to get current directory:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <heliconZoo>
            <application name="python.project">
                <environmentVariables>
                    <add name="PYTHONPATH" value="%APPL_PHYSICAL_PATH%\venv\lib\site-packages;%APPL_PHYSICAL_PATH%\venv\lib;%APPL_PHYSICAL_PATH%;%APPL_PHYSICAL_PATH%\project" />
                    ...
                </environmentVariables>
            </application>
  </heliconZoo>
  ...
 </system.webServer>
</configuration>


2. Update your custom wsgi file and specify his path in web.config:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
 <system.webServer>
  <heliconZoo>
            <application name="python.project">
                <environmentVariables>
                    <add name="PYTHONPATH" value="%APPL_PHYSICAL_PATH%\venv\lib\site-packages;%APPL_PHYSICAL_PATH%\venv\lib;%APPL_PHYSICAL_PATH%;%APPL_PHYSICAL_PATH%\project" />
                    <add name="WSGI_APP" value="your.wsgi" />                    ...
                </environmentVariables>
            </application>
  </heliconZoo>
  ...
 </system.webServer>
</configuration>


Note in this case you should move setup of DJANGO_SETTINGS_MODULE env variable from web.config to your wsgi file.

Also you can install Python App Template http://www.helicontech.com/zoo/gallery/ ... oject.html
and look at our instructions to run different python apps.

Thank you!

User avatar
Posts: 56
Joined: 01 Nov 2013, 01:50

Re: Setting custom django.wsgi entries

10 Nov 2013, 08:27

Hi,

Tried the 2nd approach:
<add name="WSGI_APP" value="app\django.wsgi" />

Getting error now:
STDERR

Traceback (most recent call last):
File "C:\Zoo\Workers\python\zoofcgi.py", line 1072, in <module>
run_wsgi_app(options.wsgi_app)
File "C:\Zoo\Workers\python\zoofcgi.py", line 1007, in run_wsgi_app
wsgi_app = import_function(wsgi_app_path)
File "C:\Zoo\Workers\python\zoofcgi.py", line 1021, in import_function
m = getattr(m, comp)
AttributeError: 'module' object has no attribute 'wsgi'

Any idea?

User avatar
Posts: 110
Joined: 07 Mar 2012, 10:22

Re: Setting custom django.wsgi entries

11 Nov 2013, 07:05

Hello!

WSGI_APP is python-style modules path, not filesystem path.
So if your python module named 'app' (contains __init__.py file, located in PYTHONPATH) and it has django.py with wsgi function, then your WSGI_APP is
app.django.wsgi

Please see more at http://docs.python.org/2/tutorial/modules.html

Also you can install Python App Template http://www.helicontech.com/zoo/gallery/ZooPythonProject.html
and look at our example with running WSGI application.

If you show the structure of the project and your file with wsgi application, i can give a more specific answer.

Thank you.

User avatar
Posts: 56
Joined: 01 Nov 2013, 01:50

Re: Setting custom django.wsgi entries

17 Nov 2013, 13:09

Thanks, sorted out via the 1st approach.

Return to Helicon Zoo

Who is online

Users browsing this forum: No registered users and 22 guests