Configuration

Location

NWSGI can be configured using a custom configuration section in web.config. If NWSGI is installed on IIS7 server, the <wsgi/> section is inside the <system.webServer> element.

For IIS CLassic deployments, the <wsgi /> element is inside the root <configuration> element. Add the following section to the top of your web.config:
    <configSections>
        <section name="wsgi" type="NWSGI.WsgiSection" />
    </configSections>

Details

In either case, the <wsgi /> section has the following elements (with some sample values):
    <wsgi debug="true" callable="application" enableExtenions="false" wildcardModule="~/dispatch.wsgi">
        <pythonPaths>
            <path path="C:\Users\Jeff\Documents\Repositories\PythonLibs\paste" />
        </pythonPaths>
        <wsgiEnviron>
            <variable name="CustomKey" value="CustomValue"  />
        </wsgiEnviron>
        <osEnviron>
            <variable name="DJANGO_SETTINGS_MODULE" value="mysite.settings"  />
        </osEnviron>
        <scriptMappings>
            <scriptMapping scriptName="virtual.wsgi" physicalPath="C:\HelloWorld\hello.wsgi" />
        </scriptMappings>
    </wsgi>

This allows you to manipulate NWSGI without editing the .wsgi file.
  • debug [true|false] (default = false)
    • Initialize IronPython in Debug mode (or not).
  • callable (default = "application")
    • The name of the application callable in the .wsgi file. This depends on the application being run; check it's documentation.
  • enableExtensions true (default = false)
    • This enables NWSGI's extensions to the WSGI protocol. Specifically, setting it to "true" enables environ"nwsgi.context" and disables automatic response flushing (which allows the ASP.NET Session module to work properly).
  • wildcardModule (default = null)
    • When set to a Pythoin module, NWSGI uses that module to process all requests. This is a simple way of removing the .wsgi file from URLs, but URL rewriting is strongly recommended instead.
  • pythonPaths
    • These are added to sys.path before the .wsgi script is run.
  • wsgiEnviron
    • These are added to the WSGI environ before the .wsgi script is run.
  • osEnviron
    • These are added to os.environ before the .wsgi script is run.
    • NOTE: These are not available in medium-trust.
    • IMPORTANT: These are process-wide, so if you must use them, make sure the app is in its own AppPool.
  • scriptMappings
    • Script mappings create a "virtual" .wsgi file that is aliased to a file that exists elsewhere in the filesystem. With a script mapping the .wsgi does not need to copied into the application's physical folder.

Last edited Oct 3, 2009 at 5:45 PM by jdhardy, version 5

Comments

No comments yet.