1 CodeSourcery > List Archives > qmtest
6 [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
8 [qmtest] patch: Upgrade DocumentTemplate package for python 2.5 compatibility.
10 To: qmtest@xxxxxxxxxxxxxxxx
12 Subject: [qmtest] patch: Upgrade DocumentTemplate package for python 2.5
15 From: Stefan Seefeld <stefan@xxxxxxxxxxxxxxxx>
17 Date: Fri, 09 Feb 2007 19:47:06 -0500
19 The attached patch attempts to partially replace the (very old) version of
20 the DocumentTemplate package once imported from Zope by a never version,
21 in an attempt to make QMTest compatible with python 2.5.
23 This version mainly replaces all uses of the 'regex' module by 're' (which,
24 unfortunately is not trivial due to some subtle differences between the two,
25 but it also contains some other small changes (e.g. replaces deprecated
26 calls such as atoi() by int()).
28 When using python 2.5, a warning about the (now deprecated) 'with' token
29 is issued (as that apparently will become a keyword in 2.6), so I'm looking
30 into replacing that, or merging more changes from a current Zope version
31 in, depending on which is easier.
39 stefan@xxxxxxxxxxxxxxxx
42 Modified for QMTest-2.3 by <japhy@pld-linux.org>
43 diff -ur qm-2.3.vanilla/qm/external/DocumentTemplate/DT_HTML.py qm-2.3/qm/external/DocumentTemplate/DT_HTML.py
44 --- qm-2.3.vanilla/qm/external/DocumentTemplate/DT_HTML.py 2005-02-11 17:11:16.000000000 +0100
45 +++ qm-2.3/qm/external/DocumentTemplate/DT_HTML.py 2007-07-23 22:13:09.000000000 +0200
47 ##############################################################################
49 -# Zope Public License (ZPL) Version 1.0
50 -# -------------------------------------
52 -# Copyright (c) Digital Creations. All rights reserved.
54 -# This license has been certified as Open Source(tm).
56 -# Redistribution and use in source and binary forms, with or without
57 -# modification, are permitted provided that the following conditions are
60 -# 1. Redistributions in source code must retain the above copyright
61 -# notice, this list of conditions, and the following disclaimer.
63 -# 2. Redistributions in binary form must reproduce the above copyright
64 -# notice, this list of conditions, and the following disclaimer in
65 -# the documentation and/or other materials provided with the
68 -# 3. Digital Creations requests that attribution be given to Zope
69 -# in any manner possible. Zope includes a "Powered by Zope"
70 -# button that is installed by default. While it is not a license
71 -# violation to remove this button, it is requested that the
72 -# attribution remain. A significant investment has been put
73 -# into Zope, and this effort will continue if the Zope community
74 -# continues to grow. This is one way to assure that growth.
76 -# 4. All advertising materials and documentation mentioning
77 -# features derived from or use of this software must display
78 -# the following acknowledgement:
80 -# "This product includes software developed by Digital Creations
81 -# for use in the Z Object Publishing Environment
82 -# (http://www.zope.org/)."
84 -# In the event that the product being advertised includes an
85 -# intact Zope distribution (with copyright and license included)
86 -# then this clause is waived.
88 -# 5. Names associated with Zope or Digital Creations must not be used to
89 -# endorse or promote products derived from this software without
90 -# prior written permission from Digital Creations.
92 -# 6. Modified redistributions of any form whatsoever must retain
93 -# the following acknowledgment:
95 -# "This product includes software developed by Digital Creations
96 -# for use in the Z Object Publishing Environment
97 -# (http://www.zope.org/)."
99 -# Intact (re-)distributions of any official Zope release do not
100 -# require an external acknowledgement.
102 -# 7. Modifications are encouraged but must be packaged separately as
103 -# patches to official Zope releases. Distributions that do not
104 -# clearly separate the patches from the original work must be clearly
105 -# labeled as unofficial distributions. Modifications which do not
106 -# carry the name Zope may be packaged in any form, as long as they
107 -# conform to all of the clauses above.
112 -# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
113 -# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
114 -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
115 -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
116 -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
117 -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
118 -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
119 -# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
120 -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
121 -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
122 -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
126 -# This software consists of contributions made by Digital Creations and
127 -# many individuals on behalf of Digital Creations. Specific
128 -# attributions are listed in the accompanying credits file.
131 +# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
133 +# This software is subject to the provisions of the Zope Public License,
134 +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
135 +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
136 +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
137 +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
138 +# FOR A PARTICULAR PURPOSE
140 ##############################################################################
141 """HTML formated DocumentTemplates
145 from DT_String import String, FileMixin
146 -import DT_String, regex
147 +import DT_String, re
148 from DT_Util import ParseError, str
149 -from string import strip, find, split, join, rfind, replace
153 + """ This needs to be replaced before 2.4. It's a hackaround. """
154 def search(self, text, start=0,
155 - name_match=regex.compile('[\0- ]*[a-zA-Z]+[\0- ]*').match,
156 - end_match=regex.compile('[\0- ]*\(/\|end\)',
157 - regex.casefold).match,
158 - start_search=regex.compile('[<&]').search,
159 - ent_name=regex.compile('[-a-zA-Z0-9_.]+').match,
163 + name_match=re.compile('[\000- ]*[a-zA-Z]+[\000- ]*').match,
164 + end_match=re.compile('[\000- ]*(/|end)', re.I).match,
165 + start_search=re.compile('[<&]').search,
166 + ent_name=re.compile('[-a-zA-Z0-9_.]+').match,
170 - s=start_search(text, start)
171 - if s < 0: return -1
172 + mo = start_search(text, start)
173 + if mo is None: return None
175 if text[s:s+5] == '<!--#':
177 - e=find(text,'-->',n)
178 - if e < 0: return -1
179 + e=text.find('-->',n)
180 + if e < 0: return None
183 - l=end_match(text,n)
185 - end=strip(text[n:n+l])
186 + mo =end_match(text,n)
188 + l = mo.end(0) - mo.start(0)
189 + end=text[n:n+l].strip()
193 elif text[s:s+6] == '<dtml-':
196 - e=find(text,'>',e+1)
197 - if e < 0: return -1
198 - if len(split(text[n:e],'"'))%2:
199 + e=text.find('>',e+1)
200 + if e < 0: return None
201 + if len(text[n:e].split('"'))%2:
202 # check for even number of "s inside
206 elif text[s:s+7] == '</dtml-':
209 - e=find(text,'>',e+1)
210 - if e < 0: return -1
211 - if len(split(text[n:e],'"'))%2:
212 + e=text.find('>',e+1)
213 + if e < 0: return None
214 + if len(text[n:e].split('"'))%2:
215 # check for even number of "s inside
220 if text[s:s+5] == '&dtml' and text[s+5] in '.-':
227 - if ent_name(args) == l:
231 - d[2]=d['name']='var'
233 - d[3]=d['args']=args+' html_quote'
237 - if nn >= 0 and nn < l-1:
238 + mo = ent_name(args)
240 + if mo.end(0)-mo.start(0) == l:
246 - args=(args[nn+1:]+' '+
247 - replace(args[:nn],'.',' '))
248 - d[3]=d['args']=args
251 + d[3]=d['args']=args+' html_quote'
256 + if nn >= 0 and nn < l-1:
258 + d[2]=d['name']='var'
260 + args=args[nn+1:]+' '+ \
261 + args[:nn].replace('.',' ')
262 + d[3]=d['args']=args
271 - l=name_match(text,n)
273 + mo = name_match(text,n)
274 + if mo is None: return None
275 + l = mo.end(0) - mo.start(0)
278 - name=strip(text[n:a])
279 + name=text[n:a].strip()
281 - args=strip(text[a:e])
282 + args=text[a:e].strip()
294 def group(self, *args):
295 get=self.__dict__.get
298 return tuple(map(get, args))
301 + def start(self, *args):
304 class HTML(DT_String.String):
305 """HTML Document Templates
307 return dtml_re_class()
310 - def parseTag(self, tagre, command=None, sargs=''):
311 + def parseTag(self, match_ob, command=None, sargs=''):
312 """Parse a tag using an already matched re
314 Return: tag, args, command, coname
316 coname is the name of a continue tag (e.g. else)
319 - tag, end, name, args, =tagre.group(0, 'end', 'name', 'args')
321 + tag, end, name, args = match_ob.group(0, 'end', 'name', 'args')
324 if not command or name != command.name:
325 raise ParseError, ('unexpected end tag', tag)
327 if not (args==sargs or
328 args==sargs[:l] and sargs[l:l+1] in ' \t\n'):
329 return tag, args, self.commands[name], None
332 return tag, args, None, name
334 try: return tag, args, self.commands[name], None
336 def SubTemplate(self, name): return HTML('', __name__=name)
339 - def varExtra(self,tagre): return 's'
340 + def varExtra(self, match_ob): return 's'
342 manage_edit__roles__=()
343 def manage_edit(self,data,REQUEST=None):
345 (('"'), '"'))): #"
346 if text is None: text=self.read_raw()
347 for re,name in character_entities:
348 - if find(text, re) >= 0: text=join(split(text,re),name)
349 + if text.find(re) >= 0: text=name.join(text.split(re))
354 manage_editForm__roles__=()
355 def manage_editForm(self, URL1, REQUEST):
356 '''Display doc template editing form''' #"
359 return self._manage_editForm(
363 def manage_edit(self,data,PARENTS,URL1,REQUEST):
365 newHTML=self.copy_class(data,self.globals,self.__name__)
366 - setattr(PARENTS[1],URL1[rfind(URL1,'/')+1:],newHTML)
367 + setattr(PARENTS[1],URL1[URL1.rfind('/')+1:],newHTML)
368 return self.editConfirmation(self,REQUEST)
371 @@ -367,10 +300,10 @@
372 PARENTS=[],URL1='',URL2='',REQUEST='', SUBMIT=''):
374 if SUBMIT==FactoryDefaultString: return self.manage_default(REQUEST)
375 - if find(data,'\r'):
376 - data=join(split(data,'\r\n'),'\n\r')
377 - data=join(split(data,'\n\r'),'\n')
379 + if data.find('\r'):
380 + data='\n\r'.join(data.split('\r\n'))
381 + data='\n'.join(data.split('\n\r'))
383 if self.edited_source:
384 self.edited_source=data
385 self._v_cooked=self.cook()
387 newHTML=self.__class__()
388 newHTML.__setstate__(self.__getstate__())
389 newHTML.edited_source=data
390 - setattr(PARENTS[1],URL1[rfind(URL1,'/')+1:],newHTML)
391 + setattr(PARENTS[1],URL1[URL1.rfind('/')+1:],newHTML)
392 if REQUEST: return self.editConfirmation(self,REQUEST)
393 diff -ur qm-2.3.vanilla/qm/external/DocumentTemplate/DT_In.py qm-2.3/qm/external/DocumentTemplate/DT_In.py
394 --- qm-2.3.vanilla/qm/external/DocumentTemplate/DT_In.py 2005-02-11 17:11:16.000000000 +0100
395 +++ qm-2.3/qm/external/DocumentTemplate/DT_In.py 2007-07-23 22:13:09.000000000 +0200
398 from DT_Util import ParseError, parse_params, name_param, str
399 from DT_Util import render_blocks, InstanceDict, ValidationError, VSEval, expr_globals
400 -from string import find, atoi, join, split
403 from DT_InSV import sequence_variables, opt
406 @@ -449,11 +448,11 @@
409 if type(v)==type(''):
413 - self.start_name_re=ts_regex.compile(
414 + self.start_name_re=re.compile(
416 - join(map(lambda c: "[%s]" % c, v),'')+
417 + ''.join(["[%s]" % c for c in v])+
420 name,expr=name_param(args,'in',1)
422 if index==first: kw['sequence-start']=0
425 - result=join(result, '')
426 + result=''.join(result)
432 if index==0: kw['sequence-start']=0
434 - result=join(result, '')
435 + result=''.join(result)
440 # eg <dtml in "foo" sort=akey,anotherkey>
443 - sortfields = split(sort,',') # multi sort = key1,key2
444 + sortfields = sort.split(',') # multi sort = key1,key2
445 multsort = len(sortfields) > 1 # flag: is multiple sort
456 - if type(v) is st: v=atoi(v)
457 + if type(v) is st: v=int(v)
459 diff -ur qm-2.3.vanilla/qm/external/DocumentTemplate/DT_Let.py qm-2.3/qm/external/DocumentTemplate/DT_Let.py
460 --- qm-2.3.vanilla/qm/external/DocumentTemplate/DT_Let.py 2005-02-11 17:11:16.000000000 +0100
461 +++ qm-2.3/qm/external/DocumentTemplate/DT_Let.py 2007-07-23 22:13:38.000000000 +0200
463 ##############################################################################
465 -# Zope Public License (ZPL) Version 1.0
466 -# -------------------------------------
468 -# Copyright (c) Digital Creations. All rights reserved.
470 -# This license has been certified as Open Source(tm).
472 -# Redistribution and use in source and binary forms, with or without
473 -# modification, are permitted provided that the following conditions are
476 -# 1. Redistributions in source code must retain the above copyright
477 -# notice, this list of conditions, and the following disclaimer.
479 -# 2. Redistributions in binary form must reproduce the above copyright
480 -# notice, this list of conditions, and the following disclaimer in
481 -# the documentation and/or other materials provided with the
484 -# 3. Digital Creations requests that attribution be given to Zope
485 -# in any manner possible. Zope includes a "Powered by Zope"
486 -# button that is installed by default. While it is not a license
487 -# violation to remove this button, it is requested that the
488 -# attribution remain. A significant investment has been put
489 -# into Zope, and this effort will continue if the Zope community
490 -# continues to grow. This is one way to assure that growth.
492 -# 4. All advertising materials and documentation mentioning
493 -# features derived from or use of this software must display
494 -# the following acknowledgement:
496 -# "This product includes software developed by Digital Creations
497 -# for use in the Z Object Publishing Environment
498 -# (http://www.zope.org/)."
500 -# In the event that the product being advertised includes an
501 -# intact Zope distribution (with copyright and license included)
502 -# then this clause is waived.
504 -# 5. Names associated with Zope or Digital Creations must not be used to
505 -# endorse or promote products derived from this software without
506 -# prior written permission from Digital Creations.
508 -# 6. Modified redistributions of any form whatsoever must retain
509 -# the following acknowledgment:
511 -# "This product includes software developed by Digital Creations
512 -# for use in the Z Object Publishing Environment
513 -# (http://www.zope.org/)."
515 -# Intact (re-)distributions of any official Zope release do not
516 -# require an external acknowledgement.
518 -# 7. Modifications are encouraged but must be packaged separately as
519 -# patches to official Zope releases. Distributions that do not
520 -# clearly separate the patches from the original work must be clearly
521 -# labeled as unofficial distributions. Modifications which do not
522 -# carry the name Zope may be packaged in any form, as long as they
523 -# conform to all of the clauses above.
528 -# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
529 -# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
530 -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
531 -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
532 -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
533 -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
534 -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
535 -# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
536 -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
537 -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
538 -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
542 -# This software consists of contributions made by Digital Creations and
543 -# many individuals on behalf of Digital Creations. Specific
544 -# attributions are listed in the accompanying credits file.
547 +# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
549 +# This software is subject to the provisions of the Zope Public License,
550 +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
551 +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
552 +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
553 +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
554 +# FOR A PARTICULAR PURPOSE
556 ##############################################################################
558 ''' The Let tag was contributed to Zope by and is copyright, 1999
559 Phillip J. Eby. Permission has been granted to release the Let tag
560 under the Zope Public License.
567 Variables are processed in sequence, so later assignments can
568 reference and/or overwrite the results of previous assignments,
573 -from DT_Util import render_blocks, Eval, expr_globals, ParseError, regex, strip
574 +from DT_Util import render_blocks, Eval, ParseError
575 from DT_Util import str # Probably needed due to hysterical pickles.
580 blockContinuations=()
584 def __init__(self, blocks):
585 tname, args, section = blocks[0]
588 if expr[:1]=='"' and expr[-1:]=='"' and len(expr) > 1:
591 - try: args[i] = name, Eval(expr, expr_globals).eval
592 + try: args[i] = name, Eval(expr).eval
593 except SyntaxError, v:
601 def parse_let_params(text,
604 - parmre=regex.compile(
605 - '\([\0- ]*\([^\0- =\"]+\)=\([^\0- =\"]+\)\)'),
606 - qparmre=regex.compile(
607 - '\([\0- ]*\([^\0- =\"]+\)="\([^"]*\)\"\)'),
608 + parmre=re.compile('([\000- ]*([^\000- ="]+)=([^\000- ="]+))'),
609 + qparmre=re.compile('([\000- ]*([^\000- ="]+)="([^"]*)")'),
614 - if parmre.match(text) >= 0:
615 - name=parmre.group(2)
616 - value=parmre.group(3)
617 - l=len(parmre.group(1))
618 - elif qparmre.match(text) >= 0:
619 - name=qparmre.group(2)
620 - value='"%s"' % qparmre.group(3)
621 - l=len(qparmre.group(1))
622 + mo = parmre.match(text)
623 + mo1= qparmre.match(text)
629 + elif mo1 is not None:
631 + value='"%s"' % mo1.group(3)
632 + l=len(mo1.group(1))
634 - if not text or not strip(text): return result
635 + if not text or not text.strip(): return result
636 raise ParseError, ('invalid parameter: "%s"' % text, tag)
639 result.append((name,value))
641 - text=strip(text[l:])
642 - if text: return apply(parse_let_params,(text,result,tag),parms)
643 + text=text[l:].strip()
644 + if text: return parse_let_params(text,result,tag,**parms)
647 Only in qm-2.3/qm/external/DocumentTemplate: DT_Let.py.orig
648 Only in qm-2.3/qm/external/DocumentTemplate: DT_Let.py.rej
649 Only in qm-2.3/qm/external/DocumentTemplate: DT_Let.py~
650 diff -ur qm-2.3.vanilla/qm/external/DocumentTemplate/DT_Return.py qm-2.3/qm/external/DocumentTemplate/DT_Return.py
651 --- qm-2.3.vanilla/qm/external/DocumentTemplate/DT_Return.py 2005-02-11 17:11:16.000000000 +0100
652 +++ qm-2.3/qm/external/DocumentTemplate/DT_Return.py 2007-07-23 22:13:09.000000000 +0200
654 __version__='$Revision$'[11:-2]
656 from DT_Util import parse_params, name_param, html_quote, str
657 -import regex, string, sys, regex
659 from string import find, split, join, atoi, rfind
662 diff -ur qm-2.3.vanilla/qm/external/DocumentTemplate/DT_String.py qm-2.3/qm/external/DocumentTemplate/DT_String.py
663 --- qm-2.3.vanilla/qm/external/DocumentTemplate/DT_String.py 2005-02-11 17:11:16.000000000 +0100
664 +++ qm-2.3/qm/external/DocumentTemplate/DT_String.py 2007-07-23 22:13:09.000000000 +0200
666 ##############################################################################
668 -# Zope Public License (ZPL) Version 1.0
669 -# -------------------------------------
671 -# Copyright (c) Digital Creations. All rights reserved.
673 -# This license has been certified as Open Source(tm).
675 -# Redistribution and use in source and binary forms, with or without
676 -# modification, are permitted provided that the following conditions are
679 -# 1. Redistributions in source code must retain the above copyright
680 -# notice, this list of conditions, and the following disclaimer.
682 -# 2. Redistributions in binary form must reproduce the above copyright
683 -# notice, this list of conditions, and the following disclaimer in
684 -# the documentation and/or other materials provided with the
687 -# 3. Digital Creations requests that attribution be given to Zope
688 -# in any manner possible. Zope includes a "Powered by Zope"
689 -# button that is installed by default. While it is not a license
690 -# violation to remove this button, it is requested that the
691 -# attribution remain. A significant investment has been put
692 -# into Zope, and this effort will continue if the Zope community
693 -# continues to grow. This is one way to assure that growth.
695 -# 4. All advertising materials and documentation mentioning
696 -# features derived from or use of this software must display
697 -# the following acknowledgement:
699 -# "This product includes software developed by Digital Creations
700 -# for use in the Z Object Publishing Environment
701 -# (http://www.zope.org/)."
703 -# In the event that the product being advertised includes an
704 -# intact Zope distribution (with copyright and license included)
705 -# then this clause is waived.
707 -# 5. Names associated with Zope or Digital Creations must not be used to
708 -# endorse or promote products derived from this software without
709 -# prior written permission from Digital Creations.
711 -# 6. Modified redistributions of any form whatsoever must retain
712 -# the following acknowledgment:
714 -# "This product includes software developed by Digital Creations
715 -# for use in the Z Object Publishing Environment
716 -# (http://www.zope.org/)."
718 -# Intact (re-)distributions of any official Zope release do not
719 -# require an external acknowledgement.
721 -# 7. Modifications are encouraged but must be packaged separately as
722 -# patches to official Zope releases. Distributions that do not
723 -# clearly separate the patches from the original work must be clearly
724 -# labeled as unofficial distributions. Modifications which do not
725 -# carry the name Zope may be packaged in any form, as long as they
726 -# conform to all of the clauses above.
731 -# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
732 -# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
733 -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
734 -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
735 -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
736 -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
737 -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
738 -# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
739 -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
740 -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
741 -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
745 -# This software consists of contributions made by Digital Creations and
746 -# many individuals on behalf of Digital Creations. Specific
747 -# attributions are listed in the accompanying credits file.
750 +# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
752 +# This software is subject to the provisions of the Zope Public License,
753 +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
754 +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
755 +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
756 +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
757 +# FOR A PARTICULAR PURPOSE
759 ##############################################################################
762 -from string import split, strip
763 -import regex, ts_regex
768 from DT_Util import ParseError, InstanceDict, TemplateDict, render_blocks, str
769 from DT_Var import Var, Call, Comment
780 func_code.co_varnames='self','REQUEST'
781 func_code.co_argcount=2
782 func_code.__roles__=()
785 func_defaults__roles__=()
790 parse_error__roles__=()
791 def parse_error(self, mess, tag, text, start):
792 - raise ParseError, "%s, for tag %s, on line %s of %s<p>" % (
793 - mess, self.errQuote(tag), len(split(text[:start],'\n')),
794 + raise ParseError, "%s, for tag %s, on line %s of %s" % (
795 + mess, self.errQuote(tag), len(text[:start].split('\n')),
796 self.errQuote(self.__name__))
803 - return regex.symcomp(
805 - '\(<name>[a-zA-Z0-9_/.-]+\)' # tag name
807 - '[\0- ]+' # space after tag name
808 - '\(<args>\([^)"]+\("[^"]*"\)?\)*\)' # arguments
810 - ')\(<fmt>[0-9]*[.]?[0-9]*[a-z]\|[]![]\)' # end
814 + '(?P<name>[a-zA-Z0-9_/.-]+)' # tag name
816 + '[\000- ]+' # space after tag name
817 + '(?P<args>([^\\)"]+("[^"]*")?)*)' # arguments
819 + '\\)(?P<fmt>[0-9]*[.]?[0-9]*[a-z]|[]![])' # end
822 _parseTag__roles__=()
823 - def _parseTag(self, tagre, command=None, sargs='', tt=type(())):
824 - tag, args, command, coname = self.parseTag(tagre,command,sargs)
825 + def _parseTag(self, match_ob, command=None, sargs='', tt=type(())):
826 + tag, args, command, coname = self.parseTag(match_ob,command,sargs)
827 if type(command) is tt:
828 cname, module, name = command
830 - # Subtlety: in these calls, globals() is not modified, but it
831 - # provides module context for the import statement (so it knows
832 - # to check the same directory as this file was found in).
834 - exec 'from %s import %s' % (module, name) in globals(), d
835 + exec 'from %s import %s' % (module, name) in d
837 - exec 'from DocumentTemplate.%s import %s' % (module, name) in globals(), d
838 + exec 'from DocumentTemplate.%s import %s' % (module, name) in d
840 self.commands[cname]=command
841 return tag, args, command, coname
844 - def parseTag(self, tagre, command=None, sargs=''):
845 + def parseTag(self, match_ob, command=None, sargs=''):
846 """Parse a tag using an already matched re
848 Return: tag, args, command, coname
850 coname is the name of a continue tag (e.g. else)
853 - tag, name, args, fmt =tagre.group(0, 'name', 'args', 'fmt')
854 - args=args and strip(args) or ''
855 + tag, name, args, fmt = match_ob.group(0, 'name', 'args', 'fmt')
856 + args=args and args.strip() or ''
859 if not command or name != command.name:
860 @@ -223,17 +149,18 @@
861 return tag, args, Var, None
864 - def varExtra(self,tagre):
865 - return tagre.group('fmt')
866 + def varExtra(self, match_ob):
867 + return match_ob.group('fmt')
870 def parse(self,text,start=0,result=None,tagre=None):
871 if result is None: result=[]
872 if tagre is None: tagre=self.tagre()
873 - l=tagre.search(text,start)
875 + mo = tagre.search(text,start)
879 - try: tag, args, command, coname = self._parseTag(tagre)
880 + try: tag, args, command, coname = self._parseTag(mo)
881 except ParseError, m: self.parse_error(m[0],m[1],text,l)
884 @@ -245,23 +172,25 @@
885 tag, l, args, command)
888 - if command is Var: r=command(args, self.varExtra(tagre))
889 + if command is Var: r=command(args, self.varExtra(mo))
890 else: r=command(args)
891 if hasattr(r,'simple_form'): r=r.simple_form
893 except ParseError, m: self.parse_error(m[0],tag,text,l)
895 - l=tagre.search(text,start)
896 + mo = tagre.search(text,start)
899 if text: result.append(text)
903 - def skip_eol(self, text, start, eol=regex.compile('[ \t]*\n')):
904 + def skip_eol(self, text, start, eol=re.compile('[ \t]*\n')):
905 # if block open is followed by newline, then skip past newline
906 - l=eol.match(text,start)
907 - if l > 0: start=start+l
908 + mo =eol.match(text,start)
910 + start = start + mo.end(0) - mo.start(0)
914 parse_block__roles__=()
915 @@ -277,12 +206,13 @@
919 - l=tagre.search(text,start)
920 - if l < 0: self.parse_error('No closing tag', stag, text, sloc)
921 + mo = tagre.search(text,start)
922 + if mo is None: self.parse_error('No closing tag', stag, text, sloc)
925 - try: tag, args, command, coname= self._parseTag(tagre,scommand,sa)
926 + try: tag, args, command, coname= self._parseTag(mo,scommand,sa)
927 except ParseError, m: self.parse_error(m[0],m[1], text, l)
932 if hasattr(command, 'blockContinuations'):
934 section._v_blocks=section.blocks=self.parse(text[:l],sstart)
935 section._v_cooked=None
936 blocks.append((tname,sargs,section))
939 start=self.skip_eol(text,l+len(tag))
942 @@ -315,10 +245,11 @@
943 parse_close__roles__=()
944 def parse_close(self, text, start, tagre, stag, sloc, scommand, sa):
946 - l=tagre.search(text,start)
947 - if l < 0: self.parse_error('No closing tag', stag, text, sloc)
948 + mo = tagre.search(text,start)
949 + if mo is None: self.parse_error('No closing tag', stag, text, sloc)
952 - try: tag, args, command, coname= self._parseTag(tagre,scommand,sa)
953 + try: tag, args, command, coname= self._parseTag(mo,scommand,sa)
954 except ParseError, m: self.parse_error(m[0],m[1], text, l)
959 if mapping is not None or vars:
960 self.initvars(mapping, vars)
961 - if source_string is not None:
962 + if source_string is not None:
963 self.raw=source_string
970 - cooklock=ts_regex.allocate_lock(),
971 + cooklock=thread.allocate_lock(),
975 @@ -442,13 +373,13 @@
976 containing values to be looked up. Values will be looked up
977 using getattr, so inheritence of values is supported. Note
978 that names beginning with '_' will not be looked up from the
982 The optional argument, 'mapping' is used to specify a mapping
983 object containing values to be inserted.
985 Values to be inserted may also be specified using keyword
989 Values will be inserted from one of several sources. The
990 sources, in the order in which they are consulted, are:
994 o The 'mapping' argument provided when the template was
999 # print '============================================================'
1001 # otherwise its just a normal client object.
1002 push(InstanceDict(client, md)) # Circ. Ref. 8-|
1013 # Mix-in class to abstract certain file-related attributes
1017 def __init__(self, file_name='', mapping=None, __name__='', **vars):
1019 Create a document template based on a named file.
1020 diff -ur qm-2.3.vanilla/qm/external/DocumentTemplate/DT_Util.py qm-2.3/qm/external/DocumentTemplate/DT_Util.py
1021 --- qm-2.3.vanilla/qm/external/DocumentTemplate/DT_Util.py 2005-02-14 08:01:54.000000000 +0100
1022 +++ qm-2.3/qm/external/DocumentTemplate/DT_Util.py 2007-07-23 22:13:09.000000000 +0200
1024 ##############################################################################
1026 -# Zope Public License (ZPL) Version 1.0
1027 -# -------------------------------------
1029 -# Copyright (c) Digital Creations. All rights reserved.
1031 -# This license has been certified as Open Source(tm).
1033 -# Redistribution and use in source and binary forms, with or without
1034 -# modification, are permitted provided that the following conditions are
1037 -# 1. Redistributions in source code must retain the above copyright
1038 -# notice, this list of conditions, and the following disclaimer.
1040 -# 2. Redistributions in binary form must reproduce the above copyright
1041 -# notice, this list of conditions, and the following disclaimer in
1042 -# the documentation and/or other materials provided with the
1045 -# 3. Digital Creations requests that attribution be given to Zope
1046 -# in any manner possible. Zope includes a "Powered by Zope"
1047 -# button that is installed by default. While it is not a license
1048 -# violation to remove this button, it is requested that the
1049 -# attribution remain. A significant investment has been put
1050 -# into Zope, and this effort will continue if the Zope community
1051 -# continues to grow. This is one way to assure that growth.
1053 -# 4. All advertising materials and documentation mentioning
1054 -# features derived from or use of this software must display
1055 -# the following acknowledgement:
1057 -# "This product includes software developed by Digital Creations
1058 -# for use in the Z Object Publishing Environment
1059 -# (http://www.zope.org/)."
1061 -# In the event that the product being advertised includes an
1062 -# intact Zope distribution (with copyright and license included)
1063 -# then this clause is waived.
1065 -# 5. Names associated with Zope or Digital Creations must not be used to
1066 -# endorse or promote products derived from this software without
1067 -# prior written permission from Digital Creations.
1069 -# 6. Modified redistributions of any form whatsoever must retain
1070 -# the following acknowledgment:
1072 -# "This product includes software developed by Digital Creations
1073 -# for use in the Z Object Publishing Environment
1074 -# (http://www.zope.org/)."
1076 -# Intact (re-)distributions of any official Zope release do not
1077 -# require an external acknowledgement.
1079 -# 7. Modifications are encouraged but must be packaged separately as
1080 -# patches to official Zope releases. Distributions that do not
1081 -# clearly separate the patches from the original work must be clearly
1082 -# labeled as unofficial distributions. Modifications which do not
1083 -# carry the name Zope may be packaged in any form, as long as they
1084 -# conform to all of the clauses above.
1089 -# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
1090 -# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1091 -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1092 -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
1093 -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1094 -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1095 -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
1096 -# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1097 -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1098 -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
1099 -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1103 -# This software consists of contributions made by Digital Creations and
1104 -# many individuals on behalf of Digital Creations. Specific
1105 -# attributions are listed in the accompanying credits file.
1108 +# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
1110 +# This software is subject to the provisions of the Zope Public License,
1111 +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
1112 +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
1113 +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1114 +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
1115 +# FOR A PARTICULAR PURPOSE
1117 ##############################################################################
1119 -__version__='$Revision$'[11:-2]
1121 -import regex, string, math, os
1122 -from string import strip, join, atoi, lower, split, find
1130 str=__builtins__['str'] # Waaaaa, waaaaaaaa needed for pickling waaaaa
1131 @@ -103,17 +31,18 @@
1132 (('"'), '"'))): #"
1134 for re,name in character_entities:
1135 - if find(text, re) >= 0: text=join(split(text,re),name)
1136 + if text.find(re) >= 0: text=text.split(re).join(name)
1139 def int_param(params,md,name,default=0, st=type('')):
1140 - try: v=params[name]
1142 + v = params.get(name, default)
1149 - if type(v) is st: v=atoi(v)
1151 + if isinstance(v, str):
1156 @@ -449,14 +378,10 @@
1157 def parse_params(text,
1160 - unparmre=regex.compile(
1161 - '\([\0- ]*\([^\0- =\"]+\)\)'),
1162 - qunparmre=regex.compile(
1163 - '\([\0- ]*\("[^"]*"\)\)'),
1164 - parmre=regex.compile(
1165 - '\([\0- ]*\([^\0- =\"]+\)=\([^\0- =\"]+\)\)'),
1166 - qparmre=regex.compile(
1167 - '\([\0- ]*\([^\0- =\"]+\)="\([^"]*\)\"\)'),
1168 + unparmre=re.compile('([\000- ]*([^\000- ="]+))'),
1169 + qunparmre=re.compile('([\000- ]*("[^"]*"))'),
1170 + parmre=re.compile('([\000- ]*([^\000- ="]+)=([^\000- ="]+))'),
1171 + qparmre=re.compile('([\000- ]*([^\000- ="]+)="([^"]*)")'),
1174 """Parse tag parameters
1175 @@ -482,39 +407,47 @@
1179 - if parmre.match(text) >= 0:
1180 - name=lower(parmre.group(2))
1181 - value=parmre.group(3)
1182 - l=len(parmre.group(1))
1183 - elif qparmre.match(text) >= 0:
1184 - name=lower(qparmre.group(2))
1185 - value=qparmre.group(3)
1186 - l=len(qparmre.group(1))
1187 - elif unparmre.match(text) >= 0:
1188 - name=unparmre.group(2)
1189 - l=len(unparmre.group(1))
1190 + # HACK - we precalculate all matches. Maybe we don't need them
1191 + # all. This should be fixed for performance issues
1193 + mo_p = parmre.match(text)
1194 + mo_q = qparmre.match(text)
1195 + mo_unp = unparmre.match(text)
1196 + mo_unq = qunparmre.match(text)
1199 + name=mo_p.group(2).lower()
1200 + value=mo_p.group(3)
1201 + l=len(mo_p.group(1))
1203 + name=mo_q.group(2).lower()
1204 + value=mo_q.group(3)
1205 + l=len(mo_q.group(1))
1207 + name=mo_unp.group(2)
1208 + l=len(mo_unp.group(1))
1210 if parms.has_key(name):
1211 if parms[name] is None: raise ParseError, (
1212 'Attribute %s requires a value' % name, tag)
1215 result[name]=parms[name]
1216 else: raise ParseError, (
1217 'Invalid attribute name, "%s"' % name, tag)
1220 - return apply(parse_params,(text[l:],result),parms)
1221 - elif qunparmre.match(text) >= 0:
1222 - name=qunparmre.group(2)
1223 - l=len(qunparmre.group(1))
1224 + return parse_params(text[l:],result,**parms)
1226 + name=mo_unq.group(2)
1227 + l=len(mo_unq.group(1))
1228 if result: raise ParseError, (
1229 'Invalid attribute name, "%s"' % name, tag)
1230 else: result['']=name
1231 - return apply(parse_params,(text[l:],result),parms)
1232 + return parse_params(text[l:],result,**parms)
1234 - if not text or not strip(text): return result
1235 + if not text or not text.strip(): return result
1236 raise ParseError, ('invalid parameter: "%s"' % text, tag)
1239 if not parms.has_key(name):
1241 'Invalid attribute name, "%s"' % name, tag)
1243 if type(p) is not ListType or p:
1245 'Duplicate values for attribute "%s"' % name, tag)
1250 - text=strip(text[l:])
1251 - if text: return apply(parse_params,(text,result),parms)
1252 + text=text[l:].strip()
1253 + if text: return parse_params(text,result,**parms)
1255 diff -ur qm-2.3.vanilla/qm/external/DocumentTemplate/DT_Var.py qm-2.3/qm/external/DocumentTemplate/DT_Var.py
1256 --- qm-2.3.vanilla/qm/external/DocumentTemplate/DT_Var.py 2005-02-11 17:11:16.000000000 +0100
1257 +++ qm-2.3/qm/external/DocumentTemplate/DT_Var.py 2007-07-23 22:13:09.000000000 +0200
1259 __version__='$Revision$'[11:-2]
1261 from DT_Util import parse_params, name_param, html_quote, str
1262 -import regex, string, sys, regex
1263 -from string import find, split, join, atoi, rfind
1264 +import string, re, sys
1265 from urllib import quote, quote_plus
1268 @@ -322,13 +321,13 @@
1270 if have_arg('size'):
1272 - try: size=atoi(size)
1273 + try: size=int(size)
1274 except: raise 'Document Error',(
1275 '''a <code>size</code> attribute was used in a <code>var</code>
1276 tag with a non-integer value.''')
1283 if have_arg('etc'): l=args['etc']
1286 def newline_to_br(v, name='(Unknown name)', md={}):
1288 - if find(v,'\r') >= 0: v=join(split(v,'\r'),'')
1289 - if find(v,'\n') >= 0: v=join(split(v,'\n'),'<br>\n')
1290 + if v.find('\r') >= 0: v=''.join(v.split('\r'))
1291 + if v.find('\n') >= 0: v='<br />\n'.join(v.split('\n'))
1294 def whole_dollars(v, name='(Unknown name)', md={}):
1295 @@ -373,19 +372,20 @@
1298 def thousands_commas(v, name='(Unknown name)', md={},
1299 - thou=regex.compile(
1300 - "\([0-9]\)\([0-9][0-9][0-9]\([,.]\|$\)\)").search):
1302 + r"([0-9])([0-9][0-9][0-9]([,.]|$))").search):
1309 - if vl: s='.'+join(vl,'.')
1310 + if vl: s='.'+'.'.join(vl)
1315 + while mo is not None:
1317 v=v[:l+1]+','+v[l+1:]
1322 def whole_dollars_with_commas(v, name='(Unknown name)', md={}):
1324 This is needed to securely insert values into sql
1325 string literals in templates that generate sql.
1327 - if find(v,"'") >= 0: return join(split(v,"'"),"''")
1328 + if v.find("'") >= 0: return v.replace("'", "''")
1336 - if find(val,'_') >= 0: val=join(split(val,'_'))
1337 + if val.find('_') >= 0: val=val.replace('_', ' ')
1340 modifiers=(html_quote, url_quote, url_quote_plus, newline_to_br,
1341 diff -ur qm-2.3.vanilla/qm/external/DocumentTemplate/__init__.py qm-2.3/qm/external/DocumentTemplate/__init__.py
1342 --- qm-2.3.vanilla/qm/external/DocumentTemplate/__init__.py 2005-02-11 17:11:16.000000000 +0100
1343 +++ qm-2.3/qm/external/DocumentTemplate/__init__.py 2007-07-23 22:13:09.000000000 +0200
1345 ##############################################################################
1347 -# Zope Public License (ZPL) Version 1.0
1348 -# -------------------------------------
1350 -# Copyright (c) Digital Creations. All rights reserved.
1352 -# This license has been certified as Open Source(tm).
1354 -# Redistribution and use in source and binary forms, with or without
1355 -# modification, are permitted provided that the following conditions are
1358 -# 1. Redistributions in source code must retain the above copyright
1359 -# notice, this list of conditions, and the following disclaimer.
1361 -# 2. Redistributions in binary form must reproduce the above copyright
1362 -# notice, this list of conditions, and the following disclaimer in
1363 -# the documentation and/or other materials provided with the
1366 -# 3. Digital Creations requests that attribution be given to Zope
1367 -# in any manner possible. Zope includes a "Powered by Zope"
1368 -# button that is installed by default. While it is not a license
1369 -# violation to remove this button, it is requested that the
1370 -# attribution remain. A significant investment has been put
1371 -# into Zope, and this effort will continue if the Zope community
1372 -# continues to grow. This is one way to assure that growth.
1374 -# 4. All advertising materials and documentation mentioning
1375 -# features derived from or use of this software must display
1376 -# the following acknowledgement:
1378 -# "This product includes software developed by Digital Creations
1379 -# for use in the Z Object Publishing Environment
1380 -# (http://www.zope.org/)."
1382 -# In the event that the product being advertised includes an
1383 -# intact Zope distribution (with copyright and license included)
1384 -# then this clause is waived.
1386 -# 5. Names associated with Zope or Digital Creations must not be used to
1387 -# endorse or promote products derived from this software without
1388 -# prior written permission from Digital Creations.
1390 -# 6. Modified redistributions of any form whatsoever must retain
1391 -# the following acknowledgment:
1393 -# "This product includes software developed by Digital Creations
1394 -# for use in the Z Object Publishing Environment
1395 -# (http://www.zope.org/)."
1397 -# Intact (re-)distributions of any official Zope release do not
1398 -# require an external acknowledgement.
1400 -# 7. Modifications are encouraged but must be packaged separately as
1401 -# patches to official Zope releases. Distributions that do not
1402 -# clearly separate the patches from the original work must be clearly
1403 -# labeled as unofficial distributions. Modifications which do not
1404 -# carry the name Zope may be packaged in any form, as long as they
1405 -# conform to all of the clauses above.
1410 -# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
1411 -# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1412 -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1413 -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
1414 -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1415 -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1416 -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
1417 -# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1418 -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1419 -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
1420 -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1424 -# This software consists of contributions made by Digital Creations and
1425 -# many individuals on behalf of Digital Creations. Specific
1426 -# attributions are listed in the accompanying credits file.
1429 +# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
1431 +# This software is subject to the provisions of the Zope Public License,
1432 +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
1433 +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
1434 +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1435 +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
1436 +# FOR A PARTICULAR PURPOSE
1438 ##############################################################################
1439 __doc__='''Package wrapper for Document Template
1443 __version__='$Revision$'[11:-2]
1446 - import ExtensionClass # work-around for import bug.
1447 -except ImportError: pass
1448 from DocumentTemplate import String, File, HTML, HTMLDefault, HTMLFile
1449 -from DocumentTemplate import html_quote
1450 diff -ur qm-2.3.vanilla/qm/external/DocumentTemplate/ts_regex.py qm-2.3/qm/external/DocumentTemplate/ts_regex.py
1451 --- qm-2.3.vanilla/qm/external/DocumentTemplate/ts_regex.py 2005-02-11 17:11:16.000000000 +0100
1452 +++ qm-2.3/qm/external/DocumentTemplate/ts_regex.py 2007-07-23 22:13:09.000000000 +0200
1454 -##############################################################################
1456 -# Zope Public License (ZPL) Version 1.0
1457 -# -------------------------------------
1459 -# Copyright (c) Digital Creations. All rights reserved.
1461 -# This license has been certified as Open Source(tm).
1463 -# Redistribution and use in source and binary forms, with or without
1464 -# modification, are permitted provided that the following conditions are
1467 -# 1. Redistributions in source code must retain the above copyright
1468 -# notice, this list of conditions, and the following disclaimer.
1470 -# 2. Redistributions in binary form must reproduce the above copyright
1471 -# notice, this list of conditions, and the following disclaimer in
1472 -# the documentation and/or other materials provided with the
1475 -# 3. Digital Creations requests that attribution be given to Zope
1476 -# in any manner possible. Zope includes a "Powered by Zope"
1477 -# button that is installed by default. While it is not a license
1478 -# violation to remove this button, it is requested that the
1479 -# attribution remain. A significant investment has been put
1480 -# into Zope, and this effort will continue if the Zope community
1481 -# continues to grow. This is one way to assure that growth.
1483 -# 4. All advertising materials and documentation mentioning
1484 -# features derived from or use of this software must display
1485 -# the following acknowledgement:
1487 -# "This product includes software developed by Digital Creations
1488 -# for use in the Z Object Publishing Environment
1489 -# (http://www.zope.org/)."
1491 -# In the event that the product being advertised includes an
1492 -# intact Zope distribution (with copyright and license included)
1493 -# then this clause is waived.
1495 -# 5. Names associated with Zope or Digital Creations must not be used to
1496 -# endorse or promote products derived from this software without
1497 -# prior written permission from Digital Creations.
1499 -# 6. Modified redistributions of any form whatsoever must retain
1500 -# the following acknowledgment:
1502 -# "This product includes software developed by Digital Creations
1503 -# for use in the Z Object Publishing Environment
1504 -# (http://www.zope.org/)."
1506 -# Intact (re-)distributions of any official Zope release do not
1507 -# require an external acknowledgement.
1509 -# 7. Modifications are encouraged but must be packaged separately as
1510 -# patches to official Zope releases. Distributions that do not
1511 -# clearly separate the patches from the original work must be clearly
1512 -# labeled as unofficial distributions. Modifications which do not
1513 -# carry the name Zope may be packaged in any form, as long as they
1514 -# conform to all of the clauses above.
1519 -# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
1520 -# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1521 -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1522 -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
1523 -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1524 -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1525 -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
1526 -# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1527 -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1528 -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
1529 -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1533 -# This software consists of contributions made by Digital Creations and
1534 -# many individuals on behalf of Digital Creations. Specific
1535 -# attributions are listed in the accompanying credits file.
1537 -##############################################################################
1538 -"""Provide a thread-safe interface to regex
1540 -import regex, regsub #, Sync
1541 -from regex import *
1542 -from regsub import split, sub, gsub, splitx, capwords
1547 - class allocate_lock:
1548 - def acquire(*args): pass
1549 - def release(*args): pass
1552 - class SafeFunction:
1553 - _l=thread.allocate_lock()
1557 - def __init__(self, f):
1560 - def __call__(self, *args, **kw):
1562 - try: return apply(self._f, args, kw)
1563 - finally: self._r()
1565 - split=SafeFunction(split)
1566 - sub=SafeFunction(sub)
1567 - gsub=SafeFunction(gsub)
1568 - splitx=SafeFunction(splitx)
1569 - capwords=SafeFunction(capwords)
1571 - allocate_lock=thread.allocate_lock
1578 - def __init__(self, *args):
1579 - self._r=r=apply(regex.compile,args)
1582 - def _init(self, r):
1583 - lock=allocate_lock()
1584 - self.__a=lock.acquire
1585 - self.__r=lock.release
1586 - self.translate=r.translate
1587 - self.givenpat=r.givenpat
1588 - self.realpat=r.realpat
1590 - def match(self, string, pos=0):
1592 - try: return self._r.match(string, pos)
1593 - finally: self.__r()
1595 - def search(self, string, pos=0):
1597 - try: return self._r.search(string, pos)
1598 - finally: self.__r()
1600 - def search_group(self, str, group, pos=0):
1601 - """Search a string for a pattern.
1603 - If the pattern was not found, then None is returned,
1604 - otherwise, the location where the pattern was found,
1605 - as well as any specified group are returned.
1610 - l=r.search(str, pos)
1611 - if l < 0: return None
1612 - return l, apply(r.group, group)
1613 - finally: self.__r()
1615 - def match_group(self, str, group, pos=0):
1616 - """Match a pattern against a string
1618 - If the string does not match the pattern, then None is
1619 - returned, otherwise, the length of the match, as well
1620 - as any specified group are returned.
1625 - l=r.match(str, pos)
1626 - if l < 0: return None
1627 - return l, apply(r.group, group)
1628 - finally: self.__r()
1630 - def search_regs(self, str, pos=0):
1631 - """Search a string for a pattern.
1633 - If the pattern was not found, then None is returned,
1634 - otherwise, the 'regs' attribute of the expression is
1640 - r.search(str, pos)
1642 - finally: self.__r()
1644 - def match_regs(self, str, pos=0):
1645 - """Match a pattern against a string
1647 - If the string does not match the pattern, then None is
1648 - returned, otherwise, the 'regs' attribute of the expression is
1656 - finally: self.__r()
1658 -class symcomp(compile):
1660 - def __init__(self, *args):
1661 - self._r=r=apply(regex.symcomp,args)
1663 - self.groupindex=r.groupindex
1669 diff -ur qm-2.3.vanilla/qm/web.py qm-2.3/qm/web.py
1670 --- qm-2.3.vanilla/qm/web.py 2005-02-25 12:02:22.000000000 +0100
1671 +++ qm-2.3/qm/web.py 2007-07-23 22:13:09.000000000 +0200
1675 import qm.external.DocumentTemplate as DocumentTemplate
1676 +sys.path.insert(1, os.path.dirname(os.path.dirname(DocumentTemplate.__file__)))
1678 ########################################################################