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):

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.


You received this message because you are subscribed to the Google Groups 
"" group.
To post to this group, send email to
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to