[Zope-Checkins] CVS: Zope/lib/python/DocumentTemplate - html_quote.py:1.1.78.2
Toby Dickenson
tdickenson@geminidataloggers.com
Thu, 7 Mar 2002 08:07:32 -0500
Update of /cvs-repository/Zope/lib/python/DocumentTemplate
In directory cvs.zope.org:/tmp/cvs-serv25817/lib/python/DocumentTemplate
Modified Files:
Tag: toby-unicode-branch
html_quote.py
Log Message:
second phase of unicode patch merge
=== Zope/lib/python/DocumentTemplate/html_quote.py 1.1.78.1 => 1.1.78.2 ===
from cgi import escape
-from types import StringType, UnicodeType
+from ustr import ustr
def html_quote(v, name='(Unknown name)', md={}):
return escape(ustr(v), 1)
-def ustr(v):
- """convert an object to a plain string or unicode string
- """
- string_types = (StringType,UnicodeType)
- if type(v) in string_types:
- return v
- else:
- try:
- fn = v.__str__
- except AttributeError:
- return str(v)
- else:
- v = fn()
- if type(v) in string_types:
- return v
- else:
- raise ValueError('__str__ returned wrong type')