Ivan Sagalaev: > Michael Radziej wrote: >> d) make the database wrapper accept both unicode and bytestrings in >> the models, but always pass unicode strings to the database backend. > Just checking if I get it right... You mean something like:
I admit that I haven't thought about the details at all. If your code works, that's great! I'm really grateful for anybody who can spend some time on the actual work. > > class CursorWrapper: > def __init__(self, cursor): > self.cursor = cursor > > def execute(command, params): > if isinstance(command, str): > command = smart_unicode(command) > params = [smart_unicode(p) for p in params] > return self.cursor.execute(command, params) > > # Delegate everything else to self.cursor > > class DatabaseWrapper: > def cursor(): > # ... > return CursorWrapper() > > I like your proposal and in case of non-unicode backends I think your > approach would work for them too: as well as unicode-capable backends > should convert everything into unicode themselves unicode-incapable > backends should convert from DEFAULT_CHARSET to 'utf-8'. Then we can set > 'utf8' for db connection universally. > >> Disadvantage: The backend will probably decode it again to get it >> across the wire, to either UTF-8 or settings.DEFAULT_CHARSET (or >> something else), adding overhead to the database communication. > > I believe this is really tiny... > >> What do you think? > > +1 with my nit about DEFAULT_CHARSET -> utf-8 for non-unicode db backends. Anton, Bjørn, Julik, Gábor, Philipp, Simon, ... (?) -- any comments on this? I'd like to make a joint proposal, tomorrow, in a new thread when we can agree on this. Michael -- noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg - Tel +49-911-9352-0 - Fax +49-911-9352-100 http://www.noris.de - The IT-Outsourcing Company --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---
