Colubrid (trun) + flup Exception

4 views
Skip to first unread message

dzu...@gmail.com

unread,
Jul 13, 2007, 3:02:28 AM7/13/07
to colubrid-users
I faced an exception when deployed my Colubrid-based application with
flup.

Stack trace:
Traceback (most recent call last):
File "/home/dmz/prj/colubrid/colubrid/debug.py", line 954, in
__call__
for line in appiter:
File "/home/dmz/prj/colubrid/colubrid/application.py", line 82, in
__iter__
return response(self.request)
File "/home/dmz/prj/colubrid/colubrid/response.py", line 154, in
__call__
request.start_response(status, headers)
File "build/bdist.linux-i686/egg/flup/server/fcgi_base.py", line
1103, in start_response
assert type(val) is str, 'Header values must be strings'
AssertionError: Header values must be strings

Reason of problem:
Somehow unicode strings appear in headers passed to flup WSGI
(start_response) and flup raises assertion.

My solution is to enforce all header strings to be a str (non-unicode)
objects.
Patch:

--- response.py (revision 3755)
+++ response.py (working copy)
@@ -148,5 +148,8 @@
headers.append(('Set-Cookie',
morsel.output(header='')))
status = '%d %s' % (self.status,
HTTP_STATUS_CODES.get(self.status,
'UNKNOWN'))
+
+ #enforce headers to be ascii strings
+ headers = [ tuple(str(s) for s in x) for x in headers ]
request.start_response(status, headers)
return self.iter_response(request.charset)

May be it's dirty hack, but it at least works.

The question is: does anybody maintain Colubrid now? Does anybody
merge this patch (or better one if any) in trunk or I have to
support my own branch of Colubrid?

I will be quite unhappy if I will have to bring my own version of
Colubrid on production servers.

Reply all
Reply to author
Forward
0 new messages