Author: japhy Date: Tue Jul 24 00:29:34 2007 GMT Module: SOURCES Tag: HEAD ---- Log message: - Patch to use QMTest with newer Python interpreters.
---- Files affected: SOURCES: QMTest-python25.patch (NONE -> 1.1) (NEW) ---- Diffs: ================================================================ Index: SOURCES/QMTest-python25.patch diff -u /dev/null SOURCES/QMTest-python25.patch:1.1 --- /dev/null Tue Jul 24 02:29:34 2007 +++ SOURCES/QMTest-python25.patch Tue Jul 24 02:29:29 2007 @@ -0,0 +1,1679 @@ +CodeSourcery > List Archives > qmtest +Actions +Post +Subscribe +Unsubscribe +[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] + +[qmtest] patch: Upgrade DocumentTemplate package for python 2.5 compatibility. + +To: [EMAIL PROTECTED] + +Subject: [qmtest] patch: Upgrade DocumentTemplate package for python 2.5 +compatibility. + +From: Stefan Seefeld <[EMAIL PROTECTED]> + +Date: Fri, 09 Feb 2007 19:47:06 -0500 + +The attached patch attempts to partially replace the (very old) version of +the DocumentTemplate package once imported from Zope by a never version, +in an attempt to make QMTest compatible with python 2.5. + +This version mainly replaces all uses of the 'regex' module by 're' (which, +unfortunately is not trivial due to some subtle differences between the two, +but it also contains some other small changes (e.g. replaces deprecated +calls such as atoi() by int()). + +When using python 2.5, a warning about the (now deprecated) 'with' token +is issued (as that apparently will become a keyword in 2.6), so I'm looking +into replacing that, or merging more changes from a current Zope version +in, depending on which is easier. + +Thanks, + Stefan + +-- +Stefan Seefeld +CodeSourcery [EMAIL PROTECTED] +(650) 331-3385 x718 + +Modified for QMTest-2.3 by <[EMAIL PROTECTED]> +diff -ur qm-2.3.vanilla/qm/external/DocumentTemplate/DT_HTML.py qm-2.3/qm/external/DocumentTemplate/DT_HTML.py +--- qm-2.3.vanilla/qm/external/DocumentTemplate/DT_HTML.py 2005-02-11 17:11:16.000000000 +0100 ++++ qm-2.3/qm/external/DocumentTemplate/DT_HTML.py 2007-07-23 22:13:09.000000000 +0200 +@@ -1,130 +1,55 @@ + ############################################################################## +-# +-# Zope Public License (ZPL) Version 1.0 +-# ------------------------------------- +-# +-# Copyright (c) Digital Creations. All rights reserved. +-# +-# This license has been certified as Open Source(tm). +-# +-# Redistribution and use in source and binary forms, with or without +-# modification, are permitted provided that the following conditions are +-# met: +-# +-# 1. Redistributions in source code must retain the above copyright +-# notice, this list of conditions, and the following disclaimer. +-# +-# 2. Redistributions in binary form must reproduce the above copyright +-# notice, this list of conditions, and the following disclaimer in +-# the documentation and/or other materials provided with the +-# distribution. +-# +-# 3. Digital Creations requests that attribution be given to Zope +-# in any manner possible. Zope includes a "Powered by Zope" +-# button that is installed by default. While it is not a license +-# violation to remove this button, it is requested that the +-# attribution remain. A significant investment has been put +-# into Zope, and this effort will continue if the Zope community +-# continues to grow. This is one way to assure that growth. +-# +-# 4. All advertising materials and documentation mentioning +-# features derived from or use of this software must display +-# the following acknowledgement: +-# +-# "This product includes software developed by Digital Creations +-# for use in the Z Object Publishing Environment +-# (http://www.zope.org/)." +-# +-# In the event that the product being advertised includes an +-# intact Zope distribution (with copyright and license included) +-# then this clause is waived. +-# +-# 5. Names associated with Zope or Digital Creations must not be used to +-# endorse or promote products derived from this software without +-# prior written permission from Digital Creations. +-# +-# 6. Modified redistributions of any form whatsoever must retain +-# the following acknowledgment: +-# +-# "This product includes software developed by Digital Creations +-# for use in the Z Object Publishing Environment +-# (http://www.zope.org/)." +-# +-# Intact (re-)distributions of any official Zope release do not +-# require an external acknowledgement. +-# +-# 7. Modifications are encouraged but must be packaged separately as +-# patches to official Zope releases. Distributions that do not +-# clearly separate the patches from the original work must be clearly +-# labeled as unofficial distributions. Modifications which do not +-# carry the name Zope may be packaged in any form, as long as they +-# conform to all of the clauses above. +-# +-# +-# Disclaimer +-# +-# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY +-# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS +-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +-# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +-# SUCH DAMAGE. +-# +-# +-# This software consists of contributions made by Digital Creations and +-# many individuals on behalf of Digital Creations. Specific +-# attributions are listed in the accompanying credits file. +-# ++# ++# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved. ++# ++# This software is subject to the provisions of the Zope Public License, ++# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. ++# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED ++# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS ++# FOR A PARTICULAR PURPOSE ++# + ############################################################################## + """HTML formated DocumentTemplates + + $Id$""" + + from DT_String import String, FileMixin +-import DT_String, regex ++import DT_String, re + from DT_Util import ParseError, str +-from string import strip, find, split, join, rfind, replace + + class dtml_re_class: +- ++ """ This needs to be replaced before 2.4. It's a hackaround. """ + def search(self, text, start=0, +- name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match, +- end_match=regex.compile('[\0- ]*\(/\|end\)', +- regex.casefold).match, +- start_search=regex.compile('[<&]').search, +- ent_name=regex.compile('[-a-zA-Z0-9_.]+').match, +- find=find, +- strip=strip, +- replace=replace, ++ name_match=re.compile('[\000- ]*[a-zA-Z]+[\000- ]*').match, ++ end_match=re.compile('[\000- ]*(/|end)', re.I).match, ++ start_search=re.compile('[<&]').search, ++ ent_name=re.compile('[-a-zA-Z0-9_.]+').match, + ): + + while 1: +- s=start_search(text, start) +- if s < 0: return -1 ++ mo = start_search(text, start) ++ if mo is None: return None ++ s = mo.start(0) + if text[s:s+5] == '<!--#': + n=s+5 +- e=find(text,'-->',n) +- if e < 0: return -1 ++ e=text.find('-->',n) ++ if e < 0: return None + en=3 + +- l=end_match(text,n) +- if l > 0: +- end=strip(text[n:n+l]) ++ mo =end_match(text,n) ++ if mo is not None: ++ l = mo.end(0) - mo.start(0) ++ end=text[n:n+l].strip() + n=n+l + else: end='' + + elif text[s:s+6] == '<dtml-': + e=n=s+6 + while 1: +- e=find(text,'>',e+1) +- if e < 0: return -1 +- if len(split(text[n:e],'"'))%2: ++ e=text.find('>',e+1) ++ if e < 0: return None ++ if len(text[n:e].split('"'))%2: + # check for even number of "s inside + break + +@@ -134,9 +60,9 @@ + elif text[s:s+7] == '</dtml-': + e=n=s+7 + while 1: +- e=find(text,'>',e+1) +- if e < 0: return -1 +- if len(split(text[n:e],'"'))%2: ++ e=text.find('>',e+1) ++ if e < 0: return None ++ if len(text[n:e].split('"'))%2: + # check for even number of "s inside + break + +@@ -146,48 +72,54 @@ + else: + if text[s:s+5] == '&dtml' and text[s+5] in '.-': + n=s+6 +- e=find(text,';',n) ++ e=text.find(';',n) + if e >= 0: + args=text[n:e] + l=len(args) +- if ent_name(args) == l: +- d=self.__dict__ +- if text[s+5]=='-': +- d[1]=d['end']='' +- d[2]=d['name']='var' +- d[0]=text[s:e+1] +- d[3]=d['args']=args+' html_quote' +- return s +- else: +- nn=find(args,'-') +- if nn >= 0 and nn < l-1: ++ mo = ent_name(args) ++ if mo is not None: ++ if mo.end(0)-mo.start(0) == l: ++ d=self.__dict__ ++ if text[s+5]=='-': + d[1]=d['end']='' + d[2]=d['name']='var' + d[0]=text[s:e+1] +- args=(args[nn+1:]+' '+ +- replace(args[:nn],'.',' ')) +- d[3]=d['args']=args +- return s +- ++ d[3]=d['args']=args+' html_quote' ++ self._start = s ++ return self ++ else: ++ nn=args.find('-') ++ if nn >= 0 and nn < l-1: ++ d[1]=d['end']='' ++ d[2]=d['name']='var' ++ d[0]=text[s:e+1] ++ args=args[nn+1:]+' '+ \ ++ args[:nn].replace('.',' ') ++ d[3]=d['args']=args ++ self._start = s ++ return self ++ + start=s+1 + continue + + break + +- l=name_match(text,n) +- if l < 0: return l ++ mo = name_match(text,n) ++ if mo is None: return None ++ l = mo.end(0) - mo.start(0) ++ + a=n+l +- name=strip(text[n:a]) ++ name=text[n:a].strip() + +- args=strip(text[a:e]) ++ args=text[a:e].strip() + + d=self.__dict__ + d[0]=text[s:e+en] + d[1]=d['end']=end + d[2]=d['name']=name + d[3]=d['args']=args +- +- return s ++ self._start = s ++ return self + + def group(self, *args): + get=self.__dict__.get +@@ -195,7 +127,8 @@ + return get(args[0]) + return tuple(map(get, args)) + +- ++ def start(self, *args): ++ return self._start + + class HTML(DT_String.String): + """HTML Document Templates +@@ -217,7 +150,7 @@ + return dtml_re_class() + + parseTag__roles__=() +- def parseTag(self, tagre, command=None, sargs=''): ++ def parseTag(self, match_ob, command=None, sargs=''): + """Parse a tag using an already matched re + + Return: tag, args, command, coname +@@ -229,8 +162,8 @@ + coname is the name of a continue tag (e.g. else) + or None otherwise + """ +- tag, end, name, args, =tagre.group(0, 'end', 'name', 'args') +- args=strip(args) ++ tag, end, name, args = match_ob.group(0, 'end', 'name', 'args') ++ args=args.strip() + if end: + if not command or name != command.name: + raise ParseError, ('unexpected end tag', tag) +@@ -245,7 +178,7 @@ + if not (args==sargs or + args==sargs[:l] and sargs[l:l+1] in ' \t\n'): + return tag, args, self.commands[name], None +- ++ + return tag, args, None, name + + try: return tag, args, self.commands[name], None +@@ -256,7 +189,7 @@ + def SubTemplate(self, name): return HTML('', __name__=name) + + varExtra__roles__=() +- def varExtra(self,tagre): return 's' ++ def varExtra(self, match_ob): return 's' + + manage_edit__roles__=() + def manage_edit(self,data,REQUEST=None): +@@ -274,7 +207,7 @@ + (('"'), '"'))): #" + if text is None: text=self.read_raw() + for re,name in character_entities: +- if find(text, re) >= 0: text=join(split(text,re),name) ++ if text.find(re) >= 0: text=name.join(text.split(re)) + return text + + errQuote__roles__=() +@@ -293,7 +226,7 @@ + manage_editForm__roles__=() + def manage_editForm(self, URL1, REQUEST): + '''Display doc template editing form''' #" +- ++ + return self._manage_editForm( + self, + mapping=REQUEST, +@@ -319,7 +252,7 @@ + def manage_edit(self,data,PARENTS,URL1,REQUEST): + 'edit a template' + newHTML=self.copy_class(data,self.globals,self.__name__) +- setattr(PARENTS[1],URL1[rfind(URL1,'/')+1:],newHTML) ++ setattr(PARENTS[1],URL1[URL1.rfind('/')+1:],newHTML) + return self.editConfirmation(self,REQUEST) + + +@@ -367,10 +300,10 @@ + PARENTS=[],URL1='',URL2='',REQUEST='', SUBMIT=''): + 'edit a template' + if SUBMIT==FactoryDefaultString: return self.manage_default(REQUEST) +- if find(data,'\r'): +- data=join(split(data,'\r\n'),'\n\r') +- data=join(split(data,'\n\r'),'\n') +- ++ if data.find('\r'): ++ data='\n\r'.join(data.split('\r\n')) ++ data='\n'.join(data.split('\n\r')) ++ + if self.edited_source: + self.edited_source=data + self._v_cooked=self.cook() +@@ -379,5 +312,5 @@ + newHTML=self.__class__() + newHTML.__setstate__(self.__getstate__()) + newHTML.edited_source=data +- setattr(PARENTS[1],URL1[rfind(URL1,'/')+1:],newHTML) ++ setattr(PARENTS[1],URL1[URL1.rfind('/')+1:],newHTML) + if REQUEST: return self.editConfirmation(self,REQUEST) +diff -ur qm-2.3.vanilla/qm/external/DocumentTemplate/DT_In.py qm-2.3/qm/external/DocumentTemplate/DT_In.py +--- qm-2.3.vanilla/qm/external/DocumentTemplate/DT_In.py 2005-02-11 17:11:16.000000000 +0100 ++++ qm-2.3/qm/external/DocumentTemplate/DT_In.py 2007-07-23 22:13:09.000000000 +0200 +@@ -387,8 +387,7 @@ + + from DT_Util import ParseError, parse_params, name_param, str + from DT_Util import render_blocks, InstanceDict, ValidationError, VSEval, expr_globals +-from string import find, atoi, join, split +-import ts_regex ++import re + from DT_InSV import sequence_variables, opt + TupleType=type(()) + +@@ -449,11 +448,11 @@ + if has_key('start'): + v=args['start'] + if type(v)==type(''): +- try: atoi(v) ++ try: int(v) + except: +- self.start_name_re=ts_regex.compile( ++ self.start_name_re=re.compile( + '&+'+ +- join(map(lambda c: "[%s]" % c, v),'')+ ++ ''.join(["[%s]" % c for c in v])+ + '=[0-9]+&+') + + name,expr=name_param(args,'in',1) +@@ -628,7 +627,7 @@ + if index==first: kw['sequence-start']=0 + + +- result=join(result, '') ++ result=''.join(result) + + finally: + if cache: pop() +@@ -712,7 +711,7 @@ + finally: pop() + if index==0: kw['sequence-start']=0 + +- result=join(result, '') ++ result=''.join(result) + + finally: + if cache: pop() +@@ -727,7 +726,7 @@ + # eg <dtml in "foo" sort=akey,anotherkey> + + sort=self.sort +- sortfields = split(sort,',') # multi sort = key1,key2 ++ sortfields = sort.split(',') # multi sort = key1,key2 + multsort = len(sortfields) > 1 # flag: is multiple sort + mapping=self.mapping + isort=not sort +@@ -784,8 +783,8 @@ + try: v=params[name] + except: v=default + if v: +- try: v=atoi(v) ++ try: v=int(v) + except: + v=md[v] +- if type(v) is st: v=atoi(v) ++ if type(v) is st: v=int(v) + return v +diff -ur qm-2.3.vanilla/qm/external/DocumentTemplate/DT_Let.py qm-2.3/qm/external/DocumentTemplate/DT_Let.py +--- qm-2.3.vanilla/qm/external/DocumentTemplate/DT_Let.py 2005-02-11 17:11:16.000000000 +0100 ++++ qm-2.3/qm/external/DocumentTemplate/DT_Let.py 2007-07-23 22:13:38.000000000 +0200 +@@ -1,92 +1,20 @@ + ############################################################################## +-# +-# Zope Public License (ZPL) Version 1.0 +-# ------------------------------------- +-# +-# Copyright (c) Digital Creations. All rights reserved. +-# +-# This license has been certified as Open Source(tm). +-# +-# Redistribution and use in source and binary forms, with or without +-# modification, are permitted provided that the following conditions are +-# met: +-# +-# 1. Redistributions in source code must retain the above copyright +-# notice, this list of conditions, and the following disclaimer. +-# +-# 2. Redistributions in binary form must reproduce the above copyright +-# notice, this list of conditions, and the following disclaimer in +-# the documentation and/or other materials provided with the +-# distribution. +-# +-# 3. Digital Creations requests that attribution be given to Zope +-# in any manner possible. Zope includes a "Powered by Zope" +-# button that is installed by default. While it is not a license +-# violation to remove this button, it is requested that the +-# attribution remain. A significant investment has been put +-# into Zope, and this effort will continue if the Zope community +-# continues to grow. This is one way to assure that growth. +-# +-# 4. All advertising materials and documentation mentioning +-# features derived from or use of this software must display +-# the following acknowledgement: +-# +-# "This product includes software developed by Digital Creations +-# for use in the Z Object Publishing Environment +-# (http://www.zope.org/)." +-# +-# In the event that the product being advertised includes an +-# intact Zope distribution (with copyright and license included) +-# then this clause is waived. +-# +-# 5. Names associated with Zope or Digital Creations must not be used to +-# endorse or promote products derived from this software without +-# prior written permission from Digital Creations. +-# +-# 6. Modified redistributions of any form whatsoever must retain +-# the following acknowledgment: +-# +-# "This product includes software developed by Digital Creations +-# for use in the Z Object Publishing Environment +-# (http://www.zope.org/)." +-# +-# Intact (re-)distributions of any official Zope release do not +-# require an external acknowledgement. +-# +-# 7. Modifications are encouraged but must be packaged separately as +-# patches to official Zope releases. Distributions that do not +-# clearly separate the patches from the original work must be clearly +-# labeled as unofficial distributions. Modifications which do not +-# carry the name Zope may be packaged in any form, as long as they +-# conform to all of the clauses above. +-# +-# +-# Disclaimer +-# +-# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY +-# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS +-# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +-# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +-# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +-# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +-# SUCH DAMAGE. +-# +-# +-# This software consists of contributions made by Digital Creations and +-# many individuals on behalf of Digital Creations. Specific +-# attributions are listed in the accompanying credits file. +-# ++# ++# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved. ++# ++# This software is subject to the provisions of the Zope Public License, ++# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. ++# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED ++# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ++# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS ++# FOR A PARTICULAR PURPOSE ++# + ############################################################################## + + ''' The Let tag was contributed to Zope by and is copyright, 1999 + Phillip J. Eby. Permission has been granted to release the Let tag + under the Zope Public License. +- ++ + + Let name=value... + +@@ -110,16 +38,17 @@ + Variables are processed in sequence, so later assignments can + reference and/or overwrite the results of previous assignments, + as desired. +-''' ++''' + +-from DT_Util import render_blocks, Eval, expr_globals, ParseError, regex, strip ++from DT_Util import render_blocks, Eval, ParseError + from DT_Util import str # Probably needed due to hysterical pickles. ++import re + + + class Let: + blockContinuations=() + name='let' +- ++ + def __init__(self, blocks): + tname, args, section = blocks[0] + self.__name__ = args +@@ -131,7 +60,7 @@ + if expr[:1]=='"' and expr[-1:]=='"' and len(expr) > 1: + # expr shorthand + expr=expr[1:-1] +- try: args[i] = name, Eval(expr, expr_globals).eval <<Diff was trimmed, longer than 597 lines>> _______________________________________________ pld-cvs-commit mailing list [email protected] http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit
