Message3959

Author JohnSJohnM
Recipients JohnSJohnM, pjenvey
Date 2008-12-18.08:40:50
SpamBayes Score 0.00026746202
Marked as misclassified No
Message-id <1229589651.57.0.381538335176.issue1207@psf.upfronthosting.co.za>
In-reply-to
Content
I did a bit of further work and managed to get Django *mostly* working; 
ie I can now see Django error pages and the built-in admin login prompt.

In ModJyServlet.java I had to change the lines

PyObject pyServlet = ((PyClass)interp.get
(MODJY_PYTHON_CLASSNAME)).__call__();

to

PyObject pyServlet = ((PyObject)interp.get
(MODJY_PYTHON_CLASSNAME)).__call__();

This solved the ClassCastException. I then had the problem with PyFile, 
as you mention; thankfully I found a blog 
(http://jblebrun.blogspot.com/2008/10/django-on-glassfish-via-
jython.html) from someone who had encountered the same problem. So in 
modjy_wsgi.py the corresponding lines using PyFile thus becomes:

dict["wsgi.input"]  = FileUtil.wrap(req.getInputStream())
dict["wsgi.errors"] =  FileUtil.wrap(System.err)

I also had to follow that guys suggestion on turning unicode back into 
strings. That finally got me to a state where I can now see Django 
pages and error messages. 

The last remaining problem seems to be that I get a Python error when 
logging in to the Django /admin pages:

Traceback:
File "/root/tomcat/webapps/ROOT/WEB-INF/lib-
python/django/django/core/handlers/base.py" in get_response
  86.                 response = callback(request, *callback_args, 
**callback_kwargs)
File "/root/tomcat/webapps/ROOT/WEB-INF/lib-
python/django/django/contrib/admin/sites.py" in root
  141.             return self.login(request)
File "/root/tomcat/webapps/ROOT/WEB-INF/lib-
python/django/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)
File "/root/tomcat/webapps/ROOT/WEB-INF/lib-
python/django/django/contrib/admin/sites.py" in login
  224.         if not request.POST.has_key(LOGIN_FORM_KEY):
File "/root/tomcat/webapps/ROOT/WEB-INF/lib-
python/django/django/core/handlers/wsgi.py" in _get_post
  169.             self._load_post_and_files()
File "/root/tomcat/webapps/ROOT/WEB-INF/lib-
python/django/django/core/handlers/wsgi.py" in _load_post_and_files
  149.                 self._post, self._files = http.QueryDict
(self.raw_post_data, encoding=self._encoding), 
datastructures.MultiValueDict()
File "/root/tomcat/webapps/ROOT/WEB-INF/lib-
python/django/django/core/handlers/wsgi.py" in _get_raw_post_data
  202.                 safe_copyfileobj(self.environ['wsgi.input'], buf,
File "/root/tomcat/webapps/ROOT/WEB-INF/lib-
python/django/django/core/handlers/wsgi.py" in safe_copyfileobj
  69.         buf = fsrc.read(min(length, size))

Exception Type: AttributeError at /admin/
Exception Value: 'str' object has no attribute 'read'

It looks pretty close to working now.
History
Date User Action Args
2008-12-18 08:40:51JohnSJohnMsetmessageid: <1229589651.57.0.381538335176.issue1207@psf.upfronthosting.co.za>
2008-12-18 08:40:51JohnSJohnMsetrecipients: + JohnSJohnM, pjenvey
2008-12-18 08:40:51JohnSJohnMlinkissue1207 messages
2008-12-18 08:40:50JohnSJohnMcreate