[IronPython] Wildcard conf on IIS6

Markus Törnqvist mjt at nysv.org
Sun Oct 18 12:52:34 CEST 2009


On Sat, Oct 17, 2009 at 02:20:38PM -0600, Jeff Hardy wrote:
>Hi Markus,

Hi!

>I finally got around to looking at this, and it looks like I missed a
>step in my documentation (such as it is...). If you check out
>http://jdhardy.blogspot.com/2009/07/nwsgi-20-removing-url-warts.html
>it gives all of the details (under the heading "Wildcards"), but I'll
>explain it here too.

I had found that by myself too, I based my conf on it ;)

>First up, you need to configure IIS 6 to serve wildcard requests for
>the application to the aspnet_isapi.dll. This is explained at
>http://professionalaspnet.com/archive/2007/07/27/Configure-IIS-for-Wildcard-Extensions-in-ASP.NET.aspx.

This I did, I think I got the hint off the list :)

>Next, you need to modify the web.config file for the application to do
>two things: first, add the <wildcard> element under <wsgi> to tell
>NWSGI that it's in wildcard mode, AND (this is the part I missed)
>change the handler mapping to be path="*" instead of path="*.wsgi".
>I've attached a web.config for the HelloWorld app that properly
>configures NWSGI for wildcard mode.

This is surprisingly close to what I have currently, and unfortunately
neither work! :|

I'm wondering about
    <wildcard physicalPath="~/hello.wsgi" />
What does ~ resolve to here?

Under unixes it's of course the home directory, and I had something like
C:\Program Files\IronPython 2.6\whatever\mysite\hello.wsgi

The Hello World stuff:

I figured I'd deploy the hello world application from commit 32122
which I had conveniently lying around. I did it by changing the
Default Web Service from the stuff I'm developing to point to a dir
with HelloWorld, with the bin subdir and all.

I also renamed the classic Web.config and accessed http://localhost/hello.wsgi
The URL http://localhost/ gave me a dir listing.

Then I changed the <wsgi><wildcard /></wsgi> definition and
<httpHandlers><add path="*" /></httpHandlers>

Now http://localhost/ works as well, hooray!

But where is the fail?
Here: http://localhost/test/

It still gives a 404; now I'm getting confused about what that wildcard
stuff is supposed to mean even :|

I'm attaching my Web.config so you can take a look, but I matched
the <wildcard physicalPath> and <add path> so I dunno, man, I dunno...

A very wild speculation would be what if Django misunderstood the path
requested, or something, and returned a 404, which IIS would catch
and replace with its own? But then again, totally valid paths in mysite
should work, so this would make no sense.

Did http://localhost/test/ work for you on your HelloWorld installation?

Any other totally random arbitrary paths?

If you have hello.wsgi like this:

def application(environ, start_response):
    """Simplest possible application object"""
    status = '200 OK'
    response_headers = [('Content-type','text/plain')]
    start_response(status, response_headers)
    env = '\n'.join('%s: %s' % (k, v) for k, v in environ.items())
    return ['Hello world!\n%s' % env]

Does it give any clues on the path stuff?

For me it obviously does not as only / is recognized :D

>I'm hoping to get a script written that will configure IIS 6 for NWSGI
>apps and skip the manual steps, but that means diving into the joy
>that is IIS 6's management API...

This would be truly awesome, but sounds like a ton of work.

Thanks! :)

-- 
mjt

-------------- next part --------------
<?xml version="1.0"?>
<configuration>
    <configSections>
        <section name="wsgi" type="NWSGI.WsgiSection, NWSGI, Version=1.99.3.0, Culture=neutral, PublicKeyToken=41e64ddc1bf1fc86" />
    </configSections>

    <wsgi frames="Full" enableExtensions="true">
        <pythonPaths>
            <path path="C:\Program Files\IronPython 2.6\Lib" />
            <path path="C:\Program Files\IronPython 2.6\Lib\site-packages" />
            <!-- PROBABLY REDUNDANT -->
            <path path="C:\Program Files\IronPython 2.6\Lib\site-packages\django" />
            <path path="C:\Program Files\IronPython 2.6\Lib\site-packages\mysite" />
        </pythonPaths>
  
  <wildcard physicalPath="~/hello.wsgi" />
  
    </wsgi>

    <location allowOverride="true">
    <system.web>
        <compilation debug="true" />
        
        <httpHandlers>
            <add verb="*" path="*" type="NWSGI.WsgiHandler, NWSGI, Version=1.99.3.0, Culture=neutral, PublicKeyToken=41e64ddc1bf1fc86" />
        </httpHandlers>

  <!-- Wonder what I was trying to achieve here :D -->
  <!--
       <securityPolicy>
          <trustLevel name="Full" policyFile="internal" />
          <trustLevel name="High" policyFile="web_hightrust.config" />
          <trustLevel name="Medium" policyFile="web_mediumtrust.config" />
          <trustLevel name="Low" policyFile="web_lowtrust.config" />
          <trustLevel name="Minimal" policyFile="web_minimaltrust.config"/>
       </securityPolicy>
       -->
       <!-- <trust 
          level="Full" 
          originUrl="" 
          processRequestInApplicationTrust="true" 
        />-->
  <!--
        <trust level="Full" originUrl="/" /> 
  -->
    </system.web>
    </location>
        
    <!-- IIS7 -->
    <system.webServer>
        <handlers>
            <add name="WsgiHandler" path="*.wsgi" verb="*" type="NWSGI.WsgiHandler, NWSGI, Version=1.99.3.0, Culture=neutral, PublicKeyToken=41e64ddc1bf1fc86" resourceType="Unspecified" />
        </handlers>
        <validation validateIntegratedModeConfiguration="false" />
    </system.webServer>
</configuration>



More information about the Ironpython-users mailing list