durusmail: quixote-users: Proposed change to _q_getname() interface
Proposed change to _q_getname() interface
2002-05-23
2002-05-23
2002-05-23
2002-05-23
2002-05-23
2002-05-23
Proposed change to _q_getname() interface
Andrew Kuchling
2002-05-23
On Thu, May 23, 2002 at 12:11:53PM -0400, Greg Ward wrote:
>> > +def isstring (x):
>> > +    return type(x) in (types.StringType, types.InstanceType)

In Python 2.2, there's types.StringTypes which is a tuple containing
the string types:

>>> import types
>>> types.StringTypes
(, )
>>> isinstance('abc', types.StringTypes)
1
>>> isinstance(u'abc', types.StringTypes)
1

In a non-Unicode build, the tuple would be one element long and the
code would continue to work.

If returning Unicode strings is allowed, then Quixote's publisher or
HTTPResponse or someone should convert it to ISO-8859-1.  (For bonus
points, look at the request object's Accept-Charset headers if
present, and convert to that encoding.)

--amk


reply