Hi,
I've tried to setup an hello world app behind cherokee using the
following recipe (as run in an ubuntu 8.04 bash shell):
django-admin.py startproject hello
cd hello
./manage.py startapp demo
cat<<"EOF" >demo/views.py
from django.http import HttpResponse
def as_string(request):
return HttpResponse("Hello world from demo.views.as_string.")
EOF
cat<<EOF> demo/urls.py
from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^as_string$', 'demo.views.as_string'),
)
EOF
vim urls.py
urlpatterns = patterns('',
(r'^demo/', include('demo.urls')),
...
)
sed -ri 's|(DATABASE_ENGINE = ).*|\1"sqlite3"|g' settings.py
sed -ri 's|(DATABASE_NAME = ).*|import
os.path;\n\1os.path.join(os.path.abspath(os.path.dirname(__file__)),
"hello.db")|g' settings.py
sed -ri 's|(INSTALLED_APPS = \()(.*)|\1\n "demo",|g' settings.py
rm settings.pyc
./manage.py syncdb --noinput
./manage.py runfcgi protocol=scgi daemonize=false
socket=/tmp/hello.sock maxrequests=1
And with the following cherokee vserver setup:
vserver!1!rule!10000!match = directory
vserver!1!rule!10000!match!directory = /demo
vserver!1!rule!10000!only_secure = 0
vserver!1!rule!10000!handler = scgi
vserver!1!rule!10000!handler!check_file = 0
vserver!1!rule!10000!handler!error_handler = 1
vserver!1!rule!10000!handler!pass_req_headers = 1
vserver!1!rule!10000!handler!xsendfile = 1
vserver!1!rule!10000!handler!allow_chunked = 1
vserver!1!rule!10000!handler!balancer = round_robin
vserver!1!rule!10000!handler!balancer!type = host
vserver!1!rule!10000!handler!balancer!1!host = /tmp/hello.sock
But when I try to access http://localhost/demo/as_string django fails to
match the request to the correct view. After some investigation, I've
came to the following facts.
Starting the django app with the normal ./manage.py runserver the SCGI
environ ends up as (I'm only showing the relevant variables):
SCRIPT_NAME
PATH_INFO /demo/
But, starting the django app with runfcgi it ends up as:
SCRIPT_NAME /demo
PATH_INFO /
Which confuses django, so to make this work I had to modify the
django/core/handlers/wsgi.py file a bit:
def __call__(self, environ, start_response):
...
if environ.get('SCGI', '0') == '1':
environ['PATH_INFO'] = environ['SCRIPT_NAME'] +
environ['PATH_INFO']
environ['SCRIPT_NAME'] = ''
NB: I'm running Django from todays trunk.
My question is, are you guys seeing this happening? is there a nicer
way to make this work?
TIA.
Best regards,
Rui Lopes
_______________________________________________
Cherokee mailing list
[email protected]
http://lists.octality.com/listinfo/cherokee