Index: lib/python/App/dtml/manage_page_header.dtml =================================================================== RCS file: /home/cvs/development/external/Zope2/lib/python/App/dtml/manage_page_header.dtml,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -c -2 -r1.1.1.1 -r1.2 *** lib/python/App/dtml/manage_page_header.dtml 2001/02/08 13:08:32 1.1.1.1 --- lib/python/App/dtml/manage_page_header.dtml 2001/02/08 17:25:12 1.2 *************** *** 2,5 **** --- 2,10 ---- + + + + + '), '>' ), (('"'), '"'))): #" ! text=str(v) ! for re,name in character_entities: if find(text, re) >= 0: text=join(split(text,re),name) return text --- 101,106 ---- (('>'), '>' ), (('"'), '"'))): #" ! text=ustr(v) ! for re,name in character_entities: if find(text, re) >= 0: text=join(split(text,re),name) return text *************** *** 209,216 **** except: from pDocumentTemplate import InstanceDict, TemplateDict, render_blocks - d=TemplateDict.__dict__ for name in ('None', 'abs', 'chr', 'divmod', 'float', 'hash', 'hex', 'int', ! 'len', 'max', 'min', 'oct', 'ord', 'round', 'str'): d[name]=__builtins__[name] d['string']=string --- 208,215 ---- except: from pDocumentTemplate import InstanceDict, TemplateDict, render_blocks d=TemplateDict.__dict__ for name in ('None', 'abs', 'chr', 'divmod', 'float', 'hash', 'hex', 'int', ! 'len', 'max', 'min', 'oct', 'ord', 'round', 'str', ! 'unicode', 'unichr', 'ustr',): d[name]=__builtins__[name] d['string']=string *************** *** 531,532 **** --- 530,550 ---- if text: return apply(parse_params,(text,result),parms) else: return result + + + def join_unicode(sequence,sep=' '): + # Unicode aware join. + # This does roughly the same job as string.join, however this function will + # not report an error if there is a mix of unicode string and 8bit strings + # with the 7th bit set. Instead, the 8bit strings are interpreted as strings + # of latin-1 characters. + # This is the preferred way of combining content for Zope responses. + try: + return join(sequence, '') + except UnicodeError: + # A mix of unicode string and normal strings with the 7th bit. + # Python considers this mix more dangerous than I do. + for i in range(len(sequence)): + if type(sequence[i]) is type(''): + sequence[i] = unicode(sequence[i],'latin-1') + return join(sequence, sep) + \ No newline at end of file Index: lib/python/DocumentTemplate/DT_Var.py =================================================================== RCS file: /home/cvs/development/external/Zope2/lib/python/DocumentTemplate/DT_Var.py,v retrieving revision 1.1.1.3 retrieving revision 1.3 diff -c -2 -r1.1.1.3 -r1.3 *** lib/python/DocumentTemplate/DT_Var.py 2001/02/08 13:08:32 1.1.1.3 --- lib/python/DocumentTemplate/DT_Var.py 2001/02/08 17:25:12 1.3 *************** *** 218,223 **** ''' # ' ! __rcs_id__='$Id: DT_Var.py,v 1.1.1.3 2001/02/08 13:08:32 tdickenson Exp $' ! __version__='$Revision: 1.1.1.3 $'[11:-2] from DT_Util import parse_params, name_param, html_quote, str --- 218,223 ---- ''' # ' ! __rcs_id__='$Id: DT_Var.py,v 1.3 2001/02/08 17:25:12 tdickenson Exp $' ! __version__='$Revision: 1.3 $'[11:-2] from DT_Util import parse_params, name_param, html_quote, str *************** *** 315,320 **** # finally, pump it through the actual string format... fmt=self.fmt ! if fmt=='s': val=str(val) ! else: val = ('%'+self.fmt) % (val,) # next, look for upper, lower, etc --- 315,322 ---- # finally, pump it through the actual string format... fmt=self.fmt ! if fmt=='s': ! val=ustr(val) ! else: ! val = ('%'+self.fmt) % (val,) # next, look for upper, lower, etc Index: lib/python/DocumentTemplate/__init__.py =================================================================== RCS file: /home/cvs/development/external/Zope2/lib/python/DocumentTemplate/__init__.py,v retrieving revision 1.1.1.1 retrieving revision 1.4 diff -c -2 -r1.1.1.1 -r1.4 *** lib/python/DocumentTemplate/__init__.py 2000/04/28 20:06:55 1.1.1.1 --- lib/python/DocumentTemplate/__init__.py 2000/09/15 14:43:28 1.4 *************** *** 88,95 **** segregated in a separate package. ! $Id: __init__.py,v 1.1.1.1 2000/04/28 20:06:55 tdickenson Exp $''' ! __version__='$Revision: 1.1.1.1 $'[11:-2] import ExtensionClass # work-around for import bug. from DocumentTemplate import String, File, HTML, HTMLDefault, HTMLFile from DocumentTemplate import html_quote --- 88,125 ---- segregated in a separate package. ! $Id: __init__.py,v 1.4 2000/09/15 14:43:28 tdickenson Exp $''' ! __version__='$Revision: 1.4 $'[11:-2] + + try: + ustr + except: + # The function ustr was intended to be included in python 2.0, but it + # didnt quite make it. It is left here as a hack, in the hope that it + # will be added as a builtin to python 2.1 + import __builtin__ + from types import StringType,UnicodeType + def ustr(v): + 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') + __builtin__.ustr = ustr + del __builtin__ + del ustr + + import ExtensionClass # work-around for import bug. from DocumentTemplate import String, File, HTML, HTMLDefault, HTMLFile from DocumentTemplate import html_quote + Index: lib/python/DocumentTemplate/cDocumentTemplate.c =================================================================== RCS file: /home/cvs/development/external/Zope2/lib/python/DocumentTemplate/cDocumentTemplate.c,v retrieving revision 1.1.1.4 retrieving revision 1.6 diff -c -2 -r1.1.1.4 -r1.6 *** lib/python/DocumentTemplate/cDocumentTemplate.c 2001/02/08 13:08:32 1.1.1.4 --- lib/python/DocumentTemplate/cDocumentTemplate.c 2001/02/08 17:25:12 1.6 *************** *** 85,94 **** static char cDocumentTemplate_module_documentation[] = "" ! "\n$Id: cDocumentTemplate.c,v 1.1.1.4 2001/02/08 13:08:32 tdickenson Exp $" ; #include "ExtensionClass.h" ! static PyObject *py_isDocTemp=0, *py_blocks=0, *py_=0, *join=0, *py_acquire; static PyObject *py___call__, *py___roles__, *py_AUTHENTICATED_USER; static PyObject *py_hasRole, *py__proxy_roles, *py_Unauthorized; --- 85,94 ---- static char cDocumentTemplate_module_documentation[] = "" ! "\n$Id: cDocumentTemplate.c,v 1.6 2001/02/08 17:25:12 tdickenson Exp $" ; #include "ExtensionClass.h" ! static PyObject *py_isDocTemp=0, *py_blocks=0, *py_=0, *join=0, *py_acquire, *ustr=0; static PyObject *py___call__, *py___roles__, *py_AUTHENTICATED_USER; static PyObject *py_hasRole, *py__proxy_roles, *py_Unauthorized; *************** *** 776,780 **** if (PyString_Check(block)) block=PyObject_GetItem(md,block); else block=PyObject_CallObject(block,mda); ! if (block) ASSIGN(block, PyObject_Str(block)); UNLESS(block) return -1; } --- 776,780 ---- if (PyString_Check(block)) block=PyObject_GetItem(md,block); else block=PyObject_CallObject(block,mda); ! if (block) ASSIGN(block,PyObject_CallFunction(ustr,"O",block)); UNLESS(block) return -1; } *************** *** 853,857 **** } } ! else if (PyString_Check(block)) { Py_INCREF(block); --- 853,857 ---- } } ! else if (PyString_Check(block) || PyUnicode_Check(block)) { Py_INCREF(block); *************** *** 873,880 **** } static PyObject * render_blocks(PyObject *self, PyObject *args) { ! PyObject *md, *blocks, *mda=0, *rendered=0; int l; --- 873,909 ---- } + + static int + render_unicode_fixup(PyObject *list) + { + PyObject *string,*unicode; + int i,l; + + l = PyList_Size(list); + + for(i=0;i + *************** *** 41,45 **** ! --- 43,47 ---- ! *************** *** 65,82 **** "> ! ! "> CHECKED> ! ! "> ! ! ! ! --- 67,84 ---- "> ! ! "> CHECKED> ! ! "> ! ! ! ! *************** *** 86,90 ****
!