Sunday, July 27, 2008

Django on IronPython, Part II

Progress! The admin module (mostly) works. I've cobbled together an SQLite module that works with the existing backend, and made quite a few workarounds. This is encouraging.

Thursday, July 24, 2008

Django on IronPython

The very basics of Django will work on IronPython. Now I need to hook up a database and see how that works. There are a few minor changes required to work around some IronPython bugs, but nothing major. I'll post them later. Note that this is using NWSGI 0.3 + Cassini; I don't know if the Django webserver works. EDIT: Here is the subversion patch:
Index: http/__init__.py
===================================================================
--- http/__init__.py (revision 8069)
+++ http/__init__.py (working copy)
@@ -14,7 +14,7 @@
 from django.http.multipartparser import MultiPartParser
 from django.conf import settings
 from django.core.files import uploadhandler
-from utils import *
+from django.http.utils import *

 RESERVED_CHARS="!*'();:@&=+$,/?%#[]"

Index: utils/functional.py
===================================================================
--- utils/functional.py (revision 8069)
+++ utils/functional.py (working copy)
@@ -160,10 +160,11 @@
             for resultclass in resultclasses:
                 self.__dispatch[resultclass] = {}
                 for (k, v) in resultclass.__dict__.items():
-                    setattr(self, k, self.__promise__(resultclass, k, v))
+                    if k != "__doc__":
+                        setattr(self, k, self.__promise__(resultclass, k, v))
             self._delegate_str = str in resultclasses
             self._delegate_unicode = unicode in resultclasses
-            assert not (self._delegate_str and self._delegate_unicode), "Cannot call lazy() with both str and unicode return types."
+            #~ assert not (self._delegate_str and self._delegate_unicode), "Cannot call lazy() with both str and unicode return types."
             if self._delegate_unicode:
                 # Each call to lazy() makes a new __proxy__ object, so this
                 # doesn't interfere with any other lazy() results.
Index: utils/translation/__init__.py
===================================================================
--- utils/translation/__init__.py (revision 8069)
+++ utils/translation/__init__.py (working copy)
@@ -42,9 +42,11 @@
     # Make the originally requested function call on the way out the door.
     return g['real_%s' % caller](*args, **kwargs)

+import trans_null
 g = globals()
 for name in __all__:
-    g['real_%s' % name] = delayed_loader
+    if hasattr(trans_null, name):
+        g['real_%s' % name] = getattr(trans_null, name)
 del g, delayed_loader

 def gettext_noop(message):