home / django_tickets / tickets

tickets: 8765

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
8765 2008-09-01 16:41:34 2010-09-11 03:25:44 2022-03-06 03:43:06.820600 Ready for checkin closed HTTP handling     dev fixed mod_python handler requires explicit str() cast for HttpResponse(mimetype=...) mod_python assumes content_type to be an ASCII string, while django uses unicode strings everywhere. For example, the following code: {{{ #!python att = Attachment.objects.get() return HttpResponse(content=att.file, mimetype=att.content_type) }}} works in django dev server, but crashes in mod_python: {{{ Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch default=default_handler, arg=req, silent=hlist.silent) File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1229, in _process_target result = _execute_target(config, req, object, arg) File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line 1128, in _execute_target result = object(arg) File "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", line 210, in handler return ModPythonHandler()(req) File "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", line 193, in __call__ req.content_type = response['Content-Type'] TypeError: content_type must be a string }}} so the only way to make it work is to cast explicitely: {{{ #!python return HttpResponse(content=att.file, mimetype=str(att.content_type)) }}} The str() cast needs to be moved into core/handlers/modpython.py, which already applies it for all headers except Content-Type (since it's handled separately). nobody semenov mod_python content-type mimetype 0 1 0 0 0 0
Powered by Datasette · Queries took 0.745ms