[Chicago] Help with PyCon Talk Proposals

Carl Karsten carl at personnelware.com
Thu Nov 15 17:36:50 CET 2007


You seem to be more concerned with my problems than your talk :)

Right now I don't think I have any.  I was just sharing my experience of where I 
had problems with unicode.

As for the django thing, I was working with some code that was written about a 
year ago, and it had its own feeble workaround to whatever existed in django a 
year ago.  current django is probably better than the workaround, but no one has 
bothered to recode things.  I have a feeling this kind of problem will exist for 
a long time.

Carl K




Feihong Hsu wrote:
> No, Django has had issues with unicode in the past. However, the current SVN release finally gets it right (I hope). Django now fully supports the __unicode__() method. The following is from Django Tutorial 1 (http://www.djangoproject.com/documentation/tutorial01/).
> 
> ====================================================
> If __unicode__() doesn’t seem to work
>  If you add the __unicode__() method to your models and don’t see any change in how they’re represented, you’re most likely using an old version of Django. (This version of the tutorial is written for the latest development version of Django.) If you’re using a Subversion checkout of of Django’s development version (see the installation docs for more information), you shouldn’t have any problems.
>  If you want to stick with an older version of Django, you’ll want to switch to the Django 0.96 tutorial, because this tutorial covers several features that only exist in the Django development version.
> ...
> 
> Why __unicode__() and not __str__()?
>  If you’re familiar with Python, you might be in the habit of adding __str__() methods to your classes, not __unicode__() methods. We use __unicode__() here because Django models deal with Unicode by default. All data stored in your database is converted to Unicode when it’s returned.
>  Django models have a default __str__() method that calls __unicode__() and converts the result to a UTF-8 bytestring. This means that unicode(p) will return a Unicode string, and str(p) will return a normal string, with characters encoded as UTF-8.
>  If all of this is jibberish to you, just remember to add __unicode__() methods to your models. With any luck, things should Just Work for you.
> ====================================================
> 
>  
> It's a shame that it didn't Just Work before, but remember that Django came out of Lawrence, Kansas, where people typically aren't concerned with representing foreign characters.
> 
> - Feihong
> 
> Carl Karsten <carl at personnelware.com> wrote: Feihong Hsu wrote:
>> I'm not really familiar with Unicode issues involving email. Were you able to resolve the problem in the end?
> 
> I was told "make sure the subject are ascii to reduce being labeled as spam."
> 
> this took care of it:
> subject = safe_ascii_encode(subject)
> 
>> But I personally haven't had any database or GUI framework issues with Unicode in a long time. Well, MySQL comes to mind, but they supposedly fixed those problems.
> 
> I think there was something in the djagno unit tests that bit me.  like I hadn't 
> created the db right.
> 
> I often wonder "why doesn't this stuff just work?"  and conclude that I must not 
> understand it.
> 
> Carl K
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
> 
> 
>        
> ---------------------------------
> Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See how.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago


More information about the Chicago mailing list