[IronPython] IronPython/NWSGI 0-byte 200/404 response with HelloWorld?

Markus Törnqvist mjt at nysv.org
Sun Sep 20 17:59:41 CEST 2009


On Sun, Sep 20, 2009 at 09:46:24AM -0600, Jeff Hardy wrote:

>> osEnviron is obviously not available in medium trust, like said in
>> http://nwsgi.codeplex.com/Wiki/View.aspx?title=Configuration
>
>The documentation on the website still refers to 1.0; I just haven't
>had a chance to update it. Sorry.

That's cool :)

>> Parser Error Message: Unrecognized element 'osEnviron'.
>
>Actually, I pulled the osEnviron section out of 2.0 because it caused
>problems with medium trust. I believe you can set the settings path,
>with a WSGI variable, but that variable doesn't seem to be documented
>anywhere (I really should open a Django bug about that).

Ouch, but understandable.

>As a workaround, you can use the .wsgi script at
>http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango. I've
>tried to make NWSGI as similar to mod_wsgi as possible.

I probably should've mailed the list earlier, but I'm in the process
of doing something like that. I came up with the .wsgi and everything
mapping to it idea myself, but I'm still figuring out if this can work..

There's a lot of trouble running Django, like:
1. Had to apply a patch I got from some mercurial repo, which is OK now.
2. Had to eliminate import PIL (and figure out how to implement cropping
   and resizing algorithms in IronPython/.NET) which is OK enough now ;)
3. And finally, I got these random errors all over the place, like the
   SessionMiddleware not working, and when removing it, AuthMiddleware
   not working. The jury's still out on how OK it is.

My current showstopper is:
'module' object has no attribute 'url_patterns'

Request Method:   GET
Request URL:  http://localhost//
Exception Type:   AttributeError
Exception Value:  'module' object has no attribute 'url_patterns'

Exception Location:   C:\Program Files\IronPython 2.6\Lib\site-packages\django\core\urlresolvers.py in resolve, line 182
Python Executable:  None
Python Version:   2.6.0
Python Path:  ['C:\\Program Files\\IronPython 2.6\\Lib\\site-packages\\myapp\\', 'C:\\Program Files\\IronPython 2.6\\Lib\\site-packages\\myapp\\bin\\Lib', 'C:\\Program Files\\IronPython 2.6\\Lib', 'C:\\Program Files\\IronPython 2.6\\Lib\\site-packages', 'C:\\Program Files\\IronPython 2.6\\Lib\\site-packages\\django', 'C:\\Program Files\\IronPython 2.6\\Lib\\site-packages\\myapp']
Server time:  Sun, 20 Sep 2009 18:49:47 +0300

Does IronPython do something very different from CPython WRT imports?

I had to add import widget to django\forms\__init__.py for example, and
something similar to myapp, where it uses piston. (I might consider dropping
piston as being useless, but there's so much to hack now to get this running
that I don't care. I removed all references to admin and added that one
import and it quit complaining ;)

PS.
Despite the above traceback I can do cool stuff like
..\..\..\ipy -X:Frames manage.py shell
>>> from django.core.urlresolvers import reverse
>>> reverse('index')
'/'
>>> reverse('set_test_cookie')
'/set_test_cookie/'

Thanks!

-- 
mjt




More information about the Ironpython-users mailing list