Django

Code

Ticket #2489 (closed: fixed)

Opened 2 years ago

Last modified 1 year ago

Make everything Unicode

Reported by: adrian Assigned to: mtredinnick
Milestone: Component: Core framework
Version: Keywords: unicode-branch
Cc: rushman@mail.ru, nesh@studio-quattro.com, cw264701@ohio.edu Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 1

Description (Last modified by adrian)

At some point, we would like to make Django use Unicode objects everywhere internally, with conversion to/from a specific charset happening on input and output. This ticket is a holding place for all related discussion/links.

UnicodeInDjango is a related wiki page.

A number of tickets have been created (and closed) that related to this problem: #924, #2276, #2132.

Attachments

HttpResponse_headers.patch (1.6 kB) - added by Alex Dedul on 08/14/06 13:00:18.
capfirst.diff (0.7 kB) - added by nesh <nesh [at] studioquattro [dot] co [dot] yu> on 01/11/07 08:39:42.
small fix for capfirst filter to enable unicode strings

Change History

08/05/06 18:41:40 changed by adrian

  • description changed.

08/14/06 12:58:52 changed by Alex Dedul

After #2514 HttpResponse breaks with headers set from DB. With the following view code

def profile_dl_pgp_key(request, user_id):
    profile = get_object_or_404(UserProfile, user__pk=user_id)
    
    response = HttpResponse(mimetype='text/plain')
    response['Content-Disposition'] = 'attachment; filename=%s_public_pgp_key.asc' % profile.user.username
    response.write(profile.public_pgp_key)

    return response

this error occurs

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/local/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
    result = object(req)

  File "/usr/local/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 163, in handler
    return ModPythonHandler()(req)

  File "/usr/local/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 146, in __call__
    populate_apache_request(response, req)

  File "/usr/local/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 154, in populate_apache_request
    mod_python_req.headers_out[key] = value

TypeError: table values must be strings

Key in mod_python_req.headers_out[key] is a unicode string we got from psycopg2, so it breaks.

As a fix patch below could be used.

08/14/06 13:00:18 changed by Alex Dedul

  • attachment HttpResponse_headers.patch added.

08/14/06 13:02:26 changed by Alex Dedul

  • summary changed from Make everything Unicode to [patch] Make everything Unicode.

09/13/06 10:12:12 changed by ubernostrum

#2716 was closed in favor of this ticket.

11/24/06 09:34:03 changed by Sergey <rushman@mail.ru>

  • cc set to rushman@mail.ru.

+1 for Django unicodization

01/11/07 08:35:33 changed by nesh <nesh [at] studioquattro [dot] co [dot] yu>

  • cc changed from rushman@mail.ru to rushman@mail.ru, nesh@studioquattro.co.yu.

01/11/07 08:39:42 changed by nesh <nesh [at] studioquattro [dot] co [dot] yu>

  • attachment capfirst.diff added.

small fix for capfirst filter to enable unicode strings

01/14/07 06:26:59 changed by adurdin@gmail.com

#2376 (only ascii support in initial sql) also closed in favour of this ticket.

01/23/07 17:05:30 changed by SmileyChris

  • needs_better_patch set to 1.
  • stage changed from Unreviewed to Accepted.

In #393, filters are fixed to work with unicode strings (but currently converts objects not type basestring with str() still for now).

01/29/07 20:33:39 changed by Michael Radziej <mir@noris.de>

duplicates: #3398 (send_mass_mail), #3387 (db API for filtering queries)

01/30/07 04:21:52 changed by anonymous

in #3398 the problem was that I didn't use unicode anywhere in my source, so the bug was quite confusing.

03/31/07 18:17:33 changed by Nebojša Đorđević <nesh@studio-quattro.com>

  • cc changed from rushman@mail.ru, nesh@studioquattro.co.yu to rushman@mail.ru, nesh@studio-quattro.com.

05/14/07 10:25:37 changed by mtredinnick

  • owner changed from adrian to mtredinnick.

Oh God! I just realised this was where elephants (and useful tickets) have come to die. It's very difficult to track all of the tickets that are mentioned here because you have to carefully read every comment to work out if it's a comment about a ticket or a new ticket appearing. Since they're no longer open, it's even harder to track them any other way. It's almost the exact opposite of fun. :-(

Triagers: please do NOT close any more tickets as dupes of this one. If they have Unicode in the title or keywords (or codec or utf8), I'll find them and be able to work through things methodically. So better to put "unicode" in the keywords field.

No need to do anything with the tickets that are mentioned here, though, since I've got them on a list now.

05/22/07 23:14:53 changed by mtredinnick

  • keywords set to unicode-branch.
  • summary changed from [patch] Make everything Unicode to Make everything Unicode.

Almost of the tickets mentioned here have now been fixed on the unicode branch.

The exceptions are enhancements to slug-generation (#2276, #2716), which has to be done both in Javascript and Python. #2276 is the wrong solution altogether and #2716 is a partial fix that I'll combine with some old Javascript improvements from Bill de hÓra. But that's an enhancement (it's a slug generator, not a transliteration function, after all).

I'll close this ticket once the unicode branch has been merged into trunk.

06/27/07 12:21:44 changed by Chris Wagner <cw264701@ohio.edu>

  • cc changed from rushman@mail.ru, nesh@studio-quattro.com to rushman@mail.ru, nesh@studio-quattro.com, cw264701@ohio.edu.

07/04/07 07:11:05 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [5609]) Merged Unicode branch into trunk (r4952:5608). This should be fully backwards compatible for all practical purposes.

Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702


Add/Change #2489 (Make everything Unicode)




Change Properties
Action