Index: lib/python/DocumentTemplate/DT_In.py =================================================================== RCS file: /home/cvs/development/external/Zope2/lib/python/DocumentTemplate/DT_In.py,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -c -4 -r1.1.1.2 -r1.2 *** lib/python/DocumentTemplate/DT_In.py 2000/06/22 11:04:53 1.1.1.2 --- lib/python/DocumentTemplate/DT_In.py 2000/07/07 13:39:05 1.2 *************** *** 381,392 **** next batches, or ''' #' ! __rcs_id__='$Id: DT_In.py,v 1.1.1.2 2000/06/22 11:04:53 tdickenson Exp $' ! __version__='$Revision: 1.1.1.2 $'[11:-2] ! from DT_Util import ParseError, parse_params, name_param, str from DT_Util import render_blocks, InstanceDict, ValidationError from string import find, atoi, join, split import ts_regex from DT_InSV import sequence_variables, opt --- 381,392 ---- next batches, or ''' #' ! __rcs_id__='$Id: DT_In.py,v 1.2 2000/07/07 13:39:05 tdickenson Exp $' ! __version__='$Revision: 1.2 $'[11:-2] ! from DT_Util import ParseError, parse_params, name_param, str, join_unicode from DT_Util import render_blocks, InstanceDict, ValidationError from string import find, atoi, join, split import ts_regex from DT_InSV import sequence_variables, opt *************** *** 613,621 **** if index==first: kw['sequence-start']=0 ! result=join(result, '') finally: if cache: pop() pop() --- 613,621 ---- if index==first: kw['sequence-start']=0 ! result = join_unicode(result, '') finally: if cache: pop() pop() *************** *** 691,699 **** try: append(render(section, md)) finally: pop() if index==0: kw['sequence-start']=0 ! result=join(result, '') finally: if cache: pop() pop() --- 691,699 ---- try: append(render(section, md)) finally: pop() if index==0: kw['sequence-start']=0 ! result=join_unicode(result, '') finally: if cache: pop() pop() Index: lib/python/DocumentTemplate/DT_Try.py =================================================================== RCS file: /home/cvs/development/external/Zope2/lib/python/DocumentTemplate/DT_Try.py,v retrieving revision 1.1.1.2 retrieving revision 1.2 diff -c -4 -r1.1.1.2 -r1.2 Index: lib/python/DocumentTemplate/DT_Util.py =================================================================== RCS file: /home/cvs/development/external/Zope2/lib/python/DocumentTemplate/DT_Util.py,v retrieving revision 1.1.1.3 retrieving revision 1.6 diff -c -4 -r1.1.1.3 -r1.6 *** lib/python/DocumentTemplate/DT_Util.py 2000/07/21 09:45:37 1.1.1.3 --- lib/python/DocumentTemplate/DT_Util.py 2000/07/21 10:15:57 1.6 *************** *** 81,90 **** # many individuals on behalf of Digital Creations. Specific # attributions are listed in the accompanying credits file. # ############################################################################## ! '''$Id: DT_Util.py,v 1.1.1.3 2000/07/21 09:45:37 tdickenson Exp $''' ! __version__='$Revision: 1.1.1.3 $'[11:-2] import regex, string, math, os from string import strip, join, atoi, lower, split, find import VSEval --- 81,90 ---- # many individuals on behalf of Digital Creations. Specific # attributions are listed in the accompanying credits file. # ############################################################################## ! '''$Id: DT_Util.py,v 1.6 2000/07/21 10:15:57 tdickenson Exp $''' ! __version__='$Revision: 1.6 $'[11:-2] import regex, string, math, os from string import strip, join, atoi, lower, split, find import VSEval *************** *** 93,111 **** ParseError='Document Template Parse Error' ValidationError='Unauthorized' - def html_quote(v, name='(Unknown name)', md={}, character_entities=( (('&'), '&'), (('<'), '<' ), (('>'), '>' ), ! (('\213'), '<' ), ! (('\233'), '>' ), (('"'), '"'))): #" ! text=str(v) ! for re,name in character_entities: if find(text, re) >= 0: text=join(split(text,re),name) return text def int_param(params,md,name,default=0, st=type('')): --- 93,113 ---- ParseError='Document Template Parse Error' ValidationError='Unauthorized' def html_quote(v, name='(Unknown name)', md={}, character_entities=( (('&'), '&'), (('<'), '<' ), (('>'), '>' ), ! ! # What are these two needed for????? ! #(('\213'), '<' ), ! #(('\233'), '>' ), ! (('"'), '"'))): #" ! text=ustr(v) ! for re,name in character_entities: if find(text, re) >= 0: text=join(split(text,re),name) return text def int_param(params,md,name,default=0, st=type('')): *************** *** 209,220 **** import ExtensionClass from cDocumentTemplate import InstanceDict, TemplateDict, render_blocks 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 d['math']=math d['whrandom']=whrandom --- 211,222 ---- import ExtensionClass from cDocumentTemplate import InstanceDict, TemplateDict, render_blocks 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 d['math']=math d['whrandom']=whrandom *************** *** 532,535 **** --- 534,556 ---- text=strip(text[l:]) 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.2 retrieving revision 1.2 diff -c -4 -r1.1.1.2 -r1.2 *** lib/python/DocumentTemplate/DT_Var.py 2000/06/22 11:04:53 1.1.1.2 --- lib/python/DocumentTemplate/DT_Var.py 2000/07/07 13:39:05 1.2 *************** *** 216,225 **** without rendering the result. ''' # ' ! __rcs_id__='$Id: DT_Var.py,v 1.1.1.2 2000/06/22 11:04:53 tdickenson Exp $' ! __version__='$Revision: 1.1.1.2 $'[11:-2] from DT_Util import parse_params, name_param, html_quote, str import regex, string, sys, regex from string import find, split, join, atoi, rfind --- 216,225 ---- without rendering the result. ''' # ' ! __rcs_id__='$Id: DT_Var.py,v 1.2 2000/07/07 13:39:05 tdickenson Exp $' ! __version__='$Revision: 1.2 $'[11:-2] from DT_Util import parse_params, name_param, html_quote, str import regex, string, sys, regex from string import find, split, join, atoi, rfind *************** *** 313,322 **** else: val = fmt % val # 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 for f in self.modifiers: val=f(val) --- 313,324 ---- else: val = fmt % val # 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 for f in self.modifiers: val=f(val) 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.3 diff -c -4 -r1.1.1.1 -r1.3 *** lib/python/DocumentTemplate/__init__.py 2000/04/28 20:06:55 1.1.1.1 --- lib/python/DocumentTemplate/__init__.py 2000/07/11 11:15:16 1.3 *************** *** 86,95 **** This wrapper allows the (now many) document template modules to be 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 --- 86,111 ---- This wrapper allows the (now many) document template modules to be segregated in a separate package. ! $Id: __init__.py,v 1.3 2000/07/11 11:15:16 tdickenson Exp $''' ! __version__='$Revision: 1.3 $'[11:-2] + try: + ustr + except: + # This ustr function was not provided in early python 1.6 alpha releases + import __builtin__ + def ustr(v): + if type(v)==type(u''): + return v + else: + return str(v) + __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.3 retrieving revision 1.5 diff -c -4 -r1.1.1.3 -r1.5 *** lib/python/DocumentTemplate/cDocumentTemplate.c 2000/07/21 09:45:37 1.1.1.3 --- lib/python/DocumentTemplate/cDocumentTemplate.c 2000/09/01 13:56:37 1.5 *************** *** 83,96 **** ****************************************************************************/ static char cDocumentTemplate_module_documentation[] = "" ! "\n$Id: cDocumentTemplate.c,v 1.1.1.3 2000/07/21 09:45:37 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; static PyObject *py_Unauthorized_fmt, *py_validate; static PyObject *py__push, *py__pop, *py_aq_base; --- 83,96 ---- ****************************************************************************/ static char cDocumentTemplate_module_documentation[] = "" ! "\n$Id: cDocumentTemplate.c,v 1.5 2000/09/01 13:56:37 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; static PyObject *py_Unauthorized_fmt, *py_validate; static PyObject *py__push, *py__pop, *py_aq_base; *************** *** 737,745 **** /* Simple var */ block=PyTuple_GET_ITEM(block,0); 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; } else { --- 737,745 ---- /* Simple var */ block=PyTuple_GET_ITEM(block,0); 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; } else { *************** *** 814,822 **** if (if_finally(md,0) == -2) return -1; } } ! else if (PyString_Check(block)) { Py_INCREF(block); } else --- 814,822 ---- if (if_finally(md,0) == -2) return -1; } } ! else if (PyString_Check(block) || PyUnicode_Check(block)) { Py_INCREF(block); } else *************** *** 834,854 **** return 0; } static PyObject * render_blocks(PyObject *self, PyObject *args) { ! PyObject *md, *blocks, *mda=0, *rendered=0; int l; UNLESS(PyArg_ParseTuple(args,"OO", &blocks, &md)) return NULL; UNLESS(rendered=PyList_New(0)) goto err; UNLESS(mda=Py_BuildValue("(O)",md)) goto err; if (render_blocks_(blocks, rendered, md, mda) < 0) goto err; ! Py_DECREF(mda); l=PyList_Size(rendered); if (l==0) { --- 834,883 ---- return 0; } + + static int + render_unicode_fixup(PyObject *list) + { + PyObject *string,*unicode; + int i,l; + + l = PyList_Size(list); + + for(i=0;i= 0: ! error_message=error_value elif (type(error_value) is StringType and tagSearch(error_value) >= 0): error_message=error_value --- 231,245 ---- raise error_type, error_value, tb if not error_message: if type(error_value) is InstanceType: ! try: ! s=str(error_value) ! except: ! pass ! else: ! if tagSearch(s) >= 0: ! error_message=error_value elif (type(error_value) is StringType and tagSearch(error_value) >= 0): error_message=error_value Index: lib/python/OFS/properties.dtml =================================================================== RCS file: /home/cvs/development/external/Zope2/lib/python/OFS/properties.dtml,v retrieving revision 1.1.1.3 retrieving revision 1.8 diff -c -4 -r1.1.1.3 -r1.8 *** lib/python/OFS/properties.dtml 2000/07/21 09:45:38 1.1.1.3 --- lib/python/OFS/properties.dtml 2000/07/21 10:15:57 1.8 *************** *** 1,8 **** --- 1,24 ---- + + + Does this 'Properties' tab need to support any browsers that do not understand utf8? + I cant say 'No' for certain :-( + + + + + + + + + + + Properties + "> *************** *** 34,42 **** ! --- 50,58 ---- ! *************** *** 54,90 **** "('%s' % getProperty(id))[:-1]" html_quote>"> "> ! ! "> CHECKED> ! ! "> ! ! ! ! ! ! "> ! ! "> CHECKED> ! ! "> ! ! ! ! ! ! "> ! ! ! Type ! Value ! --- 196,229 ----

! *************** *** 214,217 **** --- 234,238 ---- + Index: lib/python/ZPublisher/Converters.py =================================================================== RCS file: /home/cvs/development/external/Zope2/lib/python/ZPublisher/Converters.py,v retrieving revision 1.1.1.2 retrieving revision 1.5 diff -c -4 -r1.1.1.2 -r1.5 *** lib/python/ZPublisher/Converters.py 2000/07/21 09:45:47 1.1.1.2 --- lib/python/ZPublisher/Converters.py 2000/07/21 10:15:57 1.5 *************** *** 81,89 **** # many individuals on behalf of Digital Creations. Specific # attributions are listed in the accompanying credits file. # ############################################################################## ! __version__='$Revision: 1.1.1.2 $'[11:-2] import regex from string import atoi, atol, atof, join, split, strip from types import ListType, TupleType --- 81,89 ---- # many individuals on behalf of Digital Creations. Specific # attributions are listed in the accompanying credits file. # ############################################################################## ! __version__='$Revision: 1.5 $'[11:-2] import regex from string import atoi, atol, atof, join, split, strip from types import ListType, TupleType *************** *** 161,168 **** --- 161,206 ---- def field2boolean(v): return v + + class _unicode_converter: + def __call__(self,v): + # Convert a regular python string. This probably doesnt do what you want, + # whatever that might be. If you are getting exceptions below, you + # probably missed the encoding tag from a form field name. Use: + #

cookies

Name Type !
Value !
" for k,v in self.cookies.items(): ! result=result + row % (html_quote(k), html_quote(v)) result=result+"

other

" for k,v in self.other.items(): if k in ('PARENTS','RESPONSE'): continue ! result=result + row % (html_quote(k), html_quote(v)) for n in "0123456789": key = "URL%s"%n try: result=result + row % (key, html_quote(self[key])) --- 862,877 ---- def __str__(self): result="

form

" row='' for k,v in self.form.items(): ! result=result + row % (html_quote(k), html_quote(`v`)) result=result+"
%s%s

cookies

" for k,v in self.cookies.items(): ! result=result + row % (html_quote(k), html_quote(`v`)) result=result+"

other

" for k,v in self.other.items(): if k in ('PARENTS','RESPONSE'): continue ! result=result + row % (html_quote(k), html_quote(`v`)) for n in "0123456789": key = "URL%s"%n try: result=result + row % (key, html_quote(self[key])) *************** *** 886,893 **** --- 899,915 ---- base64.decodestring(split(auth)[-1]), ':') return name, password + def has_codec(x): + try: + codecs.lookup(x) + except LookupError: + return 0 + else: + return 1 + + base64=None *************** *** 1028,1037 **** def __str__(self): L1 = self.__dict__.items() L1.sort() return join(map(lambda item: "%s: %s" %item, L1), ", ") - __repr__ = __str__ # Flags SEQUENCE=1 DEFAULT=2 --- 1050,1063 ---- def __str__(self): L1 = self.__dict__.items() L1.sort() return join(map(lambda item: "%s: %s" %item, L1), ", ") + + def __repr__(self): + L1 = self.__dict__.items() + L1.sort() + return join(map(lambda item: "%s: %r" %item, L1), ", ") # Flags SEQUENCE=1 DEFAULT=2 Index: lib/python/ZPublisher/HTTPResponse.py =================================================================== RCS file: /home/cvs/development/external/Zope2/lib/python/ZPublisher/HTTPResponse.py,v retrieving revision 1.1.1.3 retrieving revision 1.4 diff -c -4 -r1.1.1.3 -r1.4 *** lib/python/ZPublisher/HTTPResponse.py 2000/07/21 09:45:47 1.1.1.3 --- lib/python/ZPublisher/HTTPResponse.py 2000/07/21 10:15:57 1.4 *************** *** 83,98 **** # ############################################################################## '''CGI Response Output formatter ! $Id: HTTPResponse.py,v 1.1.1.3 2000/07/21 09:45:47 tdickenson Exp $''' ! __version__='$Revision: 1.1.1.3 $'[11:-2] import string, types, sys, regex, re from string import find, rfind, lower, upper, strip, split, join, translate ! from types import StringType, InstanceType from BaseResponse import BaseResponse nl2sp=string.maketrans('\n',' ') status_reasons={ 100: 'Continue', --- 83,99 ---- # ############################################################################## '''CGI Response Output formatter ! $Id: HTTPResponse.py,v 1.4 2000/07/21 10:15:57 tdickenson Exp $''' ! __version__='$Revision: 1.4 $'[11:-2] import string, types, sys, regex, re from string import find, rfind, lower, upper, strip, split, join, translate ! from types import StringType, InstanceType, UnicodeType from BaseResponse import BaseResponse + nl2sp=string.maketrans('\n',' ') status_reasons={ 100: 'Continue', *************** *** 290,306 **** If is_error is true then the HTML will be formatted as a Zope error message instead of a generic HTML page. ''' if not body: return self ! if type(body) is types.TupleType and len(body) == 2: title,body=body if type(body) is not types.StringType: if hasattr(body,'asHTML'): body=body.asHTML() ! body=str(body) l=len(body) if (find(body,'>')==l-1 and body[:1]=='<' and l < 200 and bogus_str_search(body) > 0): --- 291,311 ---- If is_error is true then the HTML will be formatted as a Zope error message instead of a generic HTML page. ''' if not body: return self ! if type(body) is types.TupleType and len(body) == 2: title,body=body if type(body) is not types.StringType: if hasattr(body,'asHTML'): body=body.asHTML() ! body=ustr(body) ! ! if type(body) is UnicodeType: ! body = self._encode_unicode(body) ! l=len(body) if (find(body,'>')==l-1 and body[:1]=='<' and l < 200 and bogus_str_search(body) > 0): *************** *** 317,324 **** --- 322,339 ---- self.body=str(body) self.insertBase() return self + def _encode_unicode(self,body,charset_re=re.compile(r'text/[0-9a-z]+\s*;\s*charset=([-_0-9a-z]+)(?:(?:\s*;)|\Z)',re.IGNORECASE)): + # Try to encode the Unicode data as requested. + if self.headers.has_key('content-type'): + match = charset_re.match(self.headers['content-type']) + if match: + encoding = match.group(1) + return body.encode(encoding) + # Choose a default character encoding. + return body.encode('latin1','replace') + def setBase(self,base): 'Set the base URL for the returned document.' if base[-1:] != '/': base=base+'/' self.base=base *************** *** 328,336 **** base_re_search=regex.compile('\(]+>\)', regex.casefold).search ): if (self.headers.has_key('content-type') and ! self.headers['content-type'] != 'text/html'): return if self.base: body=self.body if body: --- 343,351 ---- base_re_search=regex.compile('\(]+>\)', regex.casefold).search ): if (self.headers.has_key('content-type') and ! self.headers['content-type'][:9] != 'text/html'): return if self.base: body=self.body if body: *************** *** 618,626 **** return self except: pass b=v ! if isinstance(b,Exception): b=str(b) if fatal and t is SystemExit and v.code==0: tb=self.setBody( (str(t), --- 633,645 ---- return self except: pass b=v ! if isinstance(b,Exception): ! try: ! b=str(b) ! except: ! b = "object at %x" % id(b) if fatal and t is SystemExit and v.code==0: tb=self.setBody( (str(t), *************** *** 628,636 **** + self._traceback(t,v,tb)), is_error=1) #elif 1: self.setBody(v) ! elif type(b) is not types.StringType or tag_search(b) < 0: tb=self.setBody( (str(t), 'Sorry, a Zope error occurred.

'+ self._traceback(t,v,tb)), --- 647,655 ---- + self._traceback(t,v,tb)), is_error=1) #elif 1: self.setBody(v) ! elif type(b) is not types.StringType and type(b) is not types.UnicodeType or tag_search(b) < 0: tb=self.setBody( (str(t), 'Sorry, a Zope error occurred.

'+ self._traceback(t,v,tb)), *************** *** 687,695 **** else: c='text/plain' self.setHeader('content-type',c) else: ! isHTML = headers['content-type']=='text/html' if isHTML and end_of_header_search(self.body) < 0: lhtml=html_search(body) if lhtml >= 0: lhtml=lhtml+6 --- 706,714 ---- else: c='text/plain' self.setHeader('content-type',c) else: ! isHTML = headers['content-type'][:9]=='text/html' if isHTML and end_of_header_search(self.body) < 0: lhtml=html_search(body) if lhtml >= 0: lhtml=lhtml+6