On Dec 6, 2007 3:47 PM, Florent Aide <[EMAIL PROTECTED]> wrote:
> On Dec 6, 2007 6:24 PM, Roger Demetrescu <[EMAIL PROTECTED]> wrote:
> > Maybe we should change that code to something like:
> >
> >
> > if isinstance(v, dict):
> > res[k] = encode_utf8(v)
> > elif isinstance(v, list):
> > res[k] = [vv.encode('utf-8') for vv in v]
> > elseif isinstance(v, basestring):
> > res[k] = v.encode('utf-8')
> > else:
> > raise Exception("some warning about this unsupported type")
>
> I had the same idea in my small head :). I must also add some test
> case to make sure we don't get a regression on this part (Last time I
> committed this encode thingy I added some tests so it should be pretty
> easy to add more).
I would also do some performance improvements... like inverting the order
of the IF's.... basestring's seem to be the most common case here,
followed by dicts and lists....
if isinstance(v, basestring):
res[k] = v.encode('utf-8')
elif isinstance(v, dict):
res[k] = encode_utf8(v)
elif isinstance(v, list):
res[k] = [vv.encode('utf-8') for vv in v]
else:
raise Exception("some warning about this unsupported type")
[]s
Roger
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---