Malthe Borch wrote:
> currently the way we insert dynamic values as text into the template
> write stream is to first check if its a string at all (it could be an
> integer number), and if not, we convert it using ``str``.
> 
> we perform this check using ``isinstance`` (first for ``unicode``,
> then ``str``); perhaps we should consider checking for ``__unicode__``
> and ``__str__``; or, as a rule, always call them if present.

Didn't we decide to drop support for non-unicode string insertion
already? I was under the impression that we shouldn't deal with encoding
conversions at all inside the machinery. zope.tal and friends have a
clear Unicode-only policy as well.

In that case a simple (pseudo code):

text = 'a'
if isinstance(text, unicode):
    _write(text)
else:
    _write(unicode(text))

should be enough, shouldn't it? Feel free to experiment with using
__unicode__ instead, but I have a feeling that checking for the
attribute existence, checking if it is a callable and calling it, is
more expensive.

Hanno

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"z3c.pt" group.
To post to this group, send email to z3c_pt@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/z3c_pt?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to