I realize the subject is a little confusing but I'll try to clarify what is
going on.
If I create a django project, called foo, and run it on runserver using
jython, the url to access it will be:
http://127.0.0.1:8000/
If I have an app named bar, the url will be:
http://127.0.0.1:8000/bar/
If I wanted to access the above url from an anchor in the index.html, my
anchor tag would have an href attribute of "bar".
Contrast this with the url for the same project deployed as a war file on
Apache Tomcat:
http://localhost:8080/foo/
You'll notice there is a foo in the url. This is the servlet context is
"foo".
If I want to access an app named bar, the url will be:
http://localhost:8080/foo/bar/
The first issue I notice is that if I use the same kind of anchor on
index.html, one where the href is just "bar", instead of going to
http://localhost:8080/foo/bar/ it will go to http://localhost:8080/bar/
which obviously will give a 404 error. If I access
http://localhost:8080/foo/bar/ I can show that it does indeed exist, and
there is just some flaw in the toolchain that is not making the url work
inside of the context.
The real trouble comes in when I get to anything I need to post. I can
successfully navigate to the GET version of an update screen, but when I
POST I'll get this error:
AttributeError at /bar/update/2/
'str' object has no attribute 'read'
Request Method: POST
Request URL: http://localhost:8080/bar/update/2/
Exception Type: AttributeError
Exception Value:
'str' object has no attribute 'read'
Exception Location:
/usr/local/tomcat/webapps/catwash/WEB-INF/lib-python/django/django/core/handlers/wsgi.py
in safe_copyfileobj, line 69
Clearly the url stripped the foo context when I pushed the submit button.
I don't know of any way to fix this at the moment. The bug could be in
django-jython, or it could be in the wsgi container, or it could even be
inside django or jython. I know I posted about this before but I thought it
was a serious enough bug to warrant its own email now that I've done some
research into what is really going on.
|