[Zope3-checkins] CVS: Zope3/src/zope/documenttemplate - __init__.py:1.1.2.2 documenttemplate.py:1.1.2.3 dt_html.py:1.1.2.2 dt_if.py:1.1.2.2 dt_in.py:1.1.2.2 dt_insv.py:1.1.2.2 dt_let.py:1.1.2.2 dt_raise.py:1.1.2.2 dt_return.py:1.1.2.2 dt_string.py:1.1.2.3 dt_try.py:1.1.2.2 dt_util.py:1.1.2.2 dt_var.py:1.1.2.2 dt_with.py:1.1.2.2 pdocumenttemplate.py:1.1.2.2
Tim Peters
tim.one@comcast.net
Tue, 24 Dec 2002 21:21:36 -0500
Update of /cvs-repository/Zope3/src/zope/documenttemplate
In directory cvs.zope.org:/tmp/cvs-serv19240/src/zope/documenttemplate
Modified Files:
Tag: NameGeddon-branch
__init__.py documenttemplate.py dt_html.py dt_if.py dt_in.py
dt_insv.py dt_let.py dt_raise.py dt_return.py dt_string.py
dt_try.py dt_util.py dt_var.py dt_with.py pdocumenttemplate.py
Log Message:
Whitespace normalization, via Python's Tools/scripts/reindent.py. The
files are fixed-points of that script now. Fixed a few cases where
code relied on significant trailing whitespace (ouch).
=== Zope3/src/zope/documenttemplate/__init__.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/__init__.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/__init__.py Tue Dec 24 21:21:01 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
-#
+#
##############################################################################
"""Package wrapper for Document Template
=== Zope3/src/zope/documenttemplate/documenttemplate.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/documenttemplate/documenttemplate.py:1.1.2.2 Mon Dec 23 16:12:14 2002
+++ Zope3/src/zope/documenttemplate/documenttemplate.py Tue Dec 24 21:21:01 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
-#
+#
##############################################################################
'''Document templates with fill-in fields
@@ -61,7 +61,7 @@
<dtml-var total fmt=12.2f>
is used to insert the variable 'total' with the C format
- '12.2f'.
+ '12.2f'.
Document templates support conditional and sequence insertion
=== Zope3/src/zope/documenttemplate/dt_html.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/dt_html.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/dt_html.py Tue Dec 24 21:21:01 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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
@@ -62,7 +62,7 @@
else:
if text[s:s+5] == '&dtml' and text[s+5] in '.-':
n=s+6
- e=text.find(';', n)
+ e=text.find(';', n)
if e >= 0:
args=text[n:e]
l=len(args)
@@ -87,7 +87,7 @@
d[3]=d['args']=args
self._start = s
return self
-
+
start = s + 1
continue
@@ -171,7 +171,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
@@ -202,4 +202,3 @@
def __str__(self):
return self.quotedHTML()
-
=== Zope3/src/zope/documenttemplate/dt_if.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/dt_if.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/dt_if.py Tue Dec 24 21:21:01 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
-#
+#
##############################################################################
"""Conditional insertion
@@ -20,14 +20,14 @@
format, use::
%(if name)[
- text
+ text
%(if name)]
To include text when an object is true using the HTML
format, use::
<dtml-if name>
- text
+ text
</dtml-if name>
where 'name' is the name bound to the object.
@@ -36,14 +36,14 @@
format, use::
%(else name)[
- text
+ text
%(else name)]
To include text when an object is false using the HTML
format, use::
<dtml-else name>
- text
+ text
</dtml-else name>
Finally to include text when an object is true and to
@@ -51,10 +51,10 @@
EPFS format, use::
%(if name)[
- true text
+ true text
%(if name)]
%(else name)[
- false text
+ false text
%(else name)]
and to include text when an object is true and to
@@ -62,9 +62,9 @@
HTML format, use::
<dtml-if name>
- true text
+ true text
<dtml-else name>
- false text
+ false text
</dtml-if name>
Notes:
@@ -76,7 +76,7 @@
variable is not reevaluated.
$Id$
-"""
+"""
from zope.documenttemplate.dt_util import ParseError, parse_params, name_param, str
class If:
=== Zope3/src/zope/documenttemplate/dt_in.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/dt_in.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/dt_in.py Tue Dec 24 21:21:01 2002
@@ -2,20 +2,20 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
-#
+#
##############################################################################
"""Sequence insertion
A sequence may be inserted using an 'in' command. The 'in'
command specifies the name of a sequence object and text to
- be inserted for each element in the sequence.
+ be inserted for each element in the sequence.
The EPFS syntax for the in command is::
@@ -26,7 +26,7 @@
The HTML syntax for the in command is::
<dtml-in name>
- text
+ text
</dtml-in name>
See the example below that shows how 'if', 'else', and 'in' commands
@@ -51,12 +51,12 @@
Attributes
sort -- Define the sort order for sequence items. If an item in
- the sequence does not define
+ the sequence does not define
sort_expr -- This allows an expression to control sort order.
reverse -- Reverse the sequence (may be combined with sort). Note
- that this can cause a huge memory use in lazy activation instances.
+ that this can cause a huge memory use in lazy activation instances.
reverse_expr -- This allows reversing to be controlled by an expression.
@@ -144,7 +144,7 @@
parameter is 3.
'overlap' -- The desired overlap between batches. The
- default is no overlap.
+ default is no overlap.
Typically, only 'start' and 'size' will be specified.
@@ -312,7 +312,7 @@
- The 'next' attribute was used and their are no
next batches, or
-
+
$Id$
"""
@@ -343,7 +343,7 @@
start_name_re = None
reverse = None
sort_expr = reverse_expr = None
-
+
def __init__(self, blocks):
tname, args, section = blocks[0]
args=parse_params(args, name='', start='1',end='-1',size='10',
@@ -366,7 +366,7 @@
if has_key('reverse'):
self.reverse = args['reverse']
-
+
if has_key('mapping'):
self.mapping = args['mapping']
for n in 'start', 'size', 'end':
@@ -391,7 +391,7 @@
'&+'+
''.join(map(lambda c: "[%s]" % c, v))+
'=[0-9]+&+')
-
+
name, expr = name_param(args, 'in', 1)
if expr is not None:
expr = expr.eval
@@ -408,7 +408,7 @@
raise ParseError, (
'name in else does not match in', 'in')
self.elses = section.blocks
-
+
def renderwb(self, md):
expr = self.expr
@@ -432,7 +432,7 @@
section = self.section
params = self.args
-
+
mapping = self.mapping
if self.sort_expr is not None:
@@ -445,7 +445,7 @@
sequence = self.reverse_sequence(sequence)
elif self.reverse is not None:
sequence = self.reverse_sequence(sequence)
-
+
next = previous = 0
try:
start = int_param(params, md, 'start', 0)
@@ -530,8 +530,8 @@
# preset
kw['previous-sequence'] = 0
# now more often defined then previously
- kw['next-sequence'] = 0
-
+ kw['next-sequence'] = 0
+
if index==first or index==last:
# provide batching information
if first > 0:
@@ -556,7 +556,7 @@
kw['next-sequence-size'] = pend + 1 - pstart
except:
pass
-
+
if index == last:
kw['sequence-end'] = 1
@@ -621,7 +621,7 @@
raise 'InError', (
'Strings are not allowed as input to the in tag.')
- section = self.section
+ section = self.section
mapping = self.mapping
@@ -659,7 +659,7 @@
if index == last:
kw['sequence-end'] = 1
client = sequence[index]
-
+
if validate is not None:
try:
vv = validate(sequence, sequence, None, client, md)
@@ -671,23 +671,23 @@
kw['sequence-start'] = 0
continue
raise ValidationError, index
-
+
kw['sequence-index'] = index
if isinstance(client, TupleType) and len(client) == 2:
client = client[1]
-
+
if mapping:
push(client)
else:
push(InstanceDict(client, md))
-
+
try:
append(render(section, md))
finally:
pop()
if index == 0:
kw['sequence-start'] = 0
-
+
result = ''.join(result)
finally:
@@ -702,9 +702,9 @@
# Modified with multiple sort fields by Ross Lazarus
# April 7 2000 rossl@med.usyd.edu.au
# eg <dtml in "foo" sort=akey,anotherkey>
-
+
sort = self.sort
- sortfields = sort.split(',') # 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
@@ -721,35 +721,35 @@
v = client
if sort:
- if multsort: # More than one sort key.
- k = []
- for sk in sortfields:
- try:
- if mapping:
- akey = v[sk]
- else:
- akey = getattr(v, sk)
- except AttributeError, KeyError:
- akey = None
- if not basic_type(akey):
- try:
- akey = akey()
- except:
- pass
- k.append(akey)
- else: # One sort key.
- try:
- if mapping:
- k = v[sort]
- else:
- k = getattr(v, sort)
- except AttributeError, KeyError:
- k = None
- if not basic_type(type(k)):
- try:
- k = k()
- except:
- pass
+ if multsort: # More than one sort key.
+ k = []
+ for sk in sortfields:
+ try:
+ if mapping:
+ akey = v[sk]
+ else:
+ akey = getattr(v, sk)
+ except AttributeError, KeyError:
+ akey = None
+ if not basic_type(akey):
+ try:
+ akey = akey()
+ except:
+ pass
+ k.append(akey)
+ else: # One sort key.
+ try:
+ if mapping:
+ k = v[sort]
+ else:
+ k = getattr(v, sort)
+ except AttributeError, KeyError:
+ k = None
+ if not basic_type(type(k)):
+ try:
+ k = k()
+ except:
+ pass
s.append((k,client))
@@ -757,7 +757,7 @@
sequence = []
for k, client in s:
- sequence.append(client)
+ sequence.append(client)
return sequence
=== Zope3/src/zope/documenttemplate/dt_insv.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/dt_insv.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/dt_insv.py Tue Dec 24 21:21:01 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
-#
+#
##############################################################################
"""Sequence variables support
@@ -78,35 +78,35 @@
roman = ''
while num >= 1000:
- num = num - 1000
- roman = '%sM' % roman
+ num = num - 1000
+ roman = '%sM' % roman
while num >= 500:
- num = num - 500
- roman = '%sD' % roman
+ num = num - 500
+ roman = '%sD' % roman
while num >= 100:
- num = num - 100
- roman = '%sC' % roman
+ num = num - 100
+ roman = '%sC' % roman
while num >= 50:
- num = num - 50
- roman = '%sL' % roman
+ num = num - 50
+ roman = '%sL' % roman
while num >= 10:
- num = num - 10
- roman = '%sX' % roman
+ num = num - 10
+ roman = '%sX' % roman
while num >= 5:
- num = num - 5
- roman = '%sV' % roman
+ num = num - 5
+ roman = '%sV' % roman
while num < 5 and num >= 1:
- num = num - 1
- roman = '%sI' % roman
+ num = num - 1
+ roman = '%sI' % roman
# Replaces special cases in Roman Numerals
-
+
roman = sub('DCCCC', 'CM', roman)
roman = sub('CCCC', 'CD', roman)
roman = sub('LXXXX', 'XC', roman)
@@ -153,7 +153,7 @@
while query_string[-1:] == '&':
query_string = query_string[:-1]
if query_string:
- query_string = '&%s&' % query_string
+ query_string = '&%s&' % query_string
re = self.start_name_re
l = re.search_group(query_string, (0,))
if l:
@@ -166,7 +166,7 @@
query_string = '?'
self.data['sequence-query'] = query_string
return query_string
-
+
statistic_names = (
'total', 'count', 'min', 'max', 'median', 'mean',
@@ -233,7 +233,7 @@
if count > 1:
sumsq = sumsq * n/(n-1)
data['variance-%s' % name] = sumsq
- data['standard-deviation-%s' % name] = sqrt(sumsq)
+ data['standard-deviation-%s' % name] = sqrt(sumsq)
else:
data['variance-%s' % name] = ''
data['standard-deviation-%s' % name] = ''
@@ -380,7 +380,7 @@
if key == 'sequence-query':
return self.query()
-
+
raise KeyError, key
=== Zope3/src/zope/documenttemplate/dt_let.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/dt_let.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/dt_let.py Tue Dec 24 21:21:01 2002
@@ -2,19 +2,19 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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...
@@ -50,7 +50,7 @@
class Let:
blockContinuations = ()
name = 'let'
-
+
def __init__(self, blocks):
tname, args, section = blocks[0]
self.__name__ = args
@@ -71,7 +71,7 @@
'\n<pre>\n%s\n</pre>\n' % v[0],
'let')
-
+
def render(self, md):
d = {}
md._push(d)
@@ -96,7 +96,7 @@
parmre=re.compile('([\000- ]*([^\000- ="]+)=([^\000- ="]+))'),
qparmre=re.compile('([\000- ]*([^\000- ="]+)="([^"]*)")'),
**parms):
-
+
result = result or []
mo = parmre.match(text)
=== Zope3/src/zope/documenttemplate/dt_raise.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/dt_raise.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/dt_raise.py Tue Dec 24 21:21:01 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
-#
+#
##############################################################################
'''Raising exceptions
@@ -24,7 +24,7 @@
</dtml-if>
$Id$
-'''
+'''
from zope.documenttemplate.dt_util import parse_params, name_param, render_blocks, str
class Raise:
@@ -41,9 +41,9 @@
def render(self, md):
expr = self.expr
if expr is None:
- t = self.__name__
- if t[-5:] == 'Error' and __builtins__.has_key(t):
- t = __builtins__[t]
+ t = self.__name__
+ if t[-5:] == 'Error' and __builtins__.has_key(t):
+ t = __builtins__[t]
else:
try:
t = expr.eval(md)
=== Zope3/src/zope/documenttemplate/dt_return.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/dt_return.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/dt_return.py Tue Dec 24 21:21:01 2002
@@ -2,23 +2,23 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
-#
+#
##############################################################################
"""
$Id$
-"""
+"""
from zope.documenttemplate.dt_util import parse_params, name_param, html_quote, str
-class ReturnTag:
+class ReturnTag:
name = 'return'
expr = None
=== Zope3/src/zope/documenttemplate/dt_string.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/documenttemplate/dt_string.py:1.1.2.2 Mon Dec 23 16:12:14 2002
+++ Zope3/src/zope/documenttemplate/dt_string.py Tue Dec 24 21:21:01 2002
@@ -2,19 +2,19 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
-#
+#
##############################################################################
"""
$Id$
-"""
+"""
import re, thread
from zope.documenttemplate.dt_util import ParseError, InstanceDict, TemplateDict, render_blocks, str
@@ -41,7 +41,7 @@
%(name)s
%(in results)]
- """
+ """
# Document Templates masquerade as functions:
class func_code:
@@ -159,7 +159,7 @@
mo = tagre.search(text, start)
while mo:
l = mo.start(0)
-
+
try:
tag, args, command, coname = self._parseTag(mo)
except ParseError, m:
@@ -198,7 +198,7 @@
mo = eol.match(text, start)
if mo is not None:
start = start + mo.end(0) - mo.start(0)
-
+
return start
@@ -218,12 +218,12 @@
if mo is None:
self.parse_error('No closing tag', stag, text, sloc)
l = mo.start(0)
-
+
try:
tag, args, command, coname= self._parseTag(mo, scommand, sa)
except ParseError, m:
self.parse_error(m[0], m[1], text, l)
-
+
if command:
start = l + len(tag)
if hasattr(command, 'blockContinuations'):
@@ -237,7 +237,7 @@
self.parse(text[:l],sstart)
section._v_cooked = None
blocks.append((tname, sargs, section))
-
+
start = self.skip_eol(text, l+len(tag))
if coname:
@@ -263,7 +263,7 @@
if mo is None:
self.parse_error('No closing tag', stag, text, sloc)
l = mo.start(0)
-
+
try:
tag, args, command, coname= self._parseTag(mo, scommand, sa)
except ParseError, m:
@@ -328,7 +328,7 @@
"""Change the text or default values for a document template."""
if mapping is not None or vars:
self.initvars(mapping, vars)
- if source_string is not None:
+ if source_string is not None:
self.raw = source_string
self.cook()
@@ -349,7 +349,7 @@
finally:
cooklock.release()
-
+
def initvars(self, globals, vars):
if globals:
for k in globals.keys():
@@ -375,13 +375,13 @@
containing values to be looked up. Values will be looked up
using getattr, so inheritence of values is supported. Note
that names beginning with '_' will not be looked up from the
- client.
+ client.
The optional argument, 'mapping' is used to specify a mapping
object containing values to be inserted.
Values to be inserted may also be specified using keyword
- arguments.
+ arguments.
Values will be inserted from one of several sources. The
sources, in the order in which they are consulted, are:
@@ -396,7 +396,7 @@
created, and
o The 'mapping' argument provided when the template was
- created.
+ created.
'''
# print '============================================================'
@@ -468,8 +468,8 @@
# otherwise its just a normal client object.
push(InstanceDict(client, md)) # Circ. Ref. 8-|
pushed += 1
-
- if self._vars:
+
+ if self._vars:
push(self._vars)
pushed += 1
@@ -502,4 +502,3 @@
if k[:3] in _special: continue
d[k] = v
return d
-
=== Zope3/src/zope/documenttemplate/dt_try.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/dt_try.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/dt_try.py Tue Dec 24 21:21:01 2002
@@ -2,19 +2,19 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
-#
+#
##############################################################################
"""
$Id$
-"""
+"""
import sys, traceback
from StringIO import StringIO
@@ -27,41 +27,41 @@
class Try:
"""Zope DTML Exception handling
-
+
usage:
-
+
<dtml-try>
<dtml-except SomeError AnotherError>
<dtml-except YetAnotherError>
<dtml-except>
<dtml-else>
</dtml-try>
-
+
or:
-
+
<dtml-try>
<dtml-finally>
</dtml-try>
-
+
The DTML try tag functions quite like Python's try command.
-
+
The contents of the try tag are rendered. If an exception is raised,
then control switches to the except blocks. The first except block to
match the type of the error raised is rendered. If an except block has
no name then it matches all raised errors.
-
+
The try tag understands class-based exceptions, as well as string-based
exceptions. Note: the 'raise' tag raises string-based exceptions.
-
+
Inside the except blocks information about the error is available via
three variables.
-
+
'error_type' -- This variable is the name of the exception caught.
-
+
'error_value' -- This is the caught exception's value.
-
+
'error_tb' -- This is a traceback for the caught exception.
-
+
The optional else block is rendered when no exception occurs in the
try block. Exceptions in the else block are not handled by the preceding
except blocks.
@@ -86,10 +86,10 @@
lost.
Original version by Jordan B. Baker.
-
+
Try..finally and try..else implementation by Martijn Pieters.
"""
-
+
name = 'try'
blockContinuations = 'except', 'else', 'finally'
finallyBlock = None
@@ -168,7 +168,7 @@
errname = t.__name__
handler = self.find_handler(t)
-
+
if handler is None:
# we didn't find a handler, so reraise the error
raise
@@ -192,7 +192,7 @@
else:
return result + render_blocks(self.elseBlock, md)
-
+
def render_try_finally(self, md):
result = ''
# first try to render the first block
@@ -214,13 +214,13 @@
return None
for e,h in self.handlers:
if e==exception.__name__ or e=='' or self.match_base(exception,e):
- return h
- return None
+ return h
+ return None
def match_base(self,exception,name):
for base in exception.__bases__:
if base.__name__ == name or self.match_base(base, name):
return 1
return None
-
+
__call__ = render
=== Zope3/src/zope/documenttemplate/dt_util.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/dt_util.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/dt_util.py Tue Dec 24 21:21:01 2002
@@ -2,19 +2,19 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
-#
+#
##############################################################################
"""
$Id$
-"""
+"""
import re, math
import whrandom
@@ -34,10 +34,10 @@
(('<'), '<' ),
(('>'), '>' ),
(('"'), '"'))): #"
- text = str(v)
- for re, name in character_entities:
- text = text.replace(re, name)
- return text
+ text = str(v)
+ for re, name in character_entities:
+ text = text.replace(re, name)
+ return text
def int_param(params, md, name, default=0):
@@ -57,7 +57,7 @@
_marker=[]
def careful_getattr(md, inst, name, default=_marker):
-
+
if name[:1] != '_':
# Try to get the attribute normally so that we don't
@@ -86,16 +86,16 @@
def careful_hasattr(md, inst, name):
v=getattr(inst, name, _marker)
if v is not _marker:
- try:
+ try:
if name[:1] != '_':
- validate = md.validate
+ validate = md.validate
if validate is None:
return 1
-
+
if hasattr(inst, 'aq_acquire'):
inst.aq_acquire(name, validate, md)
return 1
-
+
if validate(inst, inst, name, v, md):
return 1
except:
@@ -251,7 +251,7 @@
k= v = i
if h(k):
del d[k]
-
+
for i in with:
if isinstance(i, TupleType) and len(i) == 2:
k, v = i
@@ -278,7 +278,7 @@
self.expr = expr
self.code = compile(expr,'<string>','eval')
-
+
def eval(self, mapping):
d={'_vars': mapping,
'_': mapping}
@@ -310,7 +310,7 @@
# # Fix up something like: <!--#in expr="whatever" mapping-->
# params[params['']]=default_unnamed
# del params['']
-
+
if used(''):
v = params['']
@@ -335,7 +335,7 @@
'that doesn\'t support expr attributes.',
tag)
- else: # name shorthand
+ else: # name shorthand
if used(attr):
raise ParseError, ('Two %s values were given' % attr, tag)
if expr:
@@ -355,7 +355,7 @@
name = params['expr']
expr = Eval(name)
return name, expr
-
+
raise ParseError, ('No %s given' % attr, tag)
@@ -385,20 +385,20 @@
mapping object. This variable can be useful for accessing objects
in a document template namespace that have names that are not legal
Python variable names::
-
+
<dtml-var expr="_['sequence-number']*5">
-
+
This variable also has attributes that provide access to standard
utility objects. These attributes include:
-
+
- The objects: 'None', 'abs', 'chr', 'divmod', 'float', 'hash',
'hex', 'int', 'len', 'max', 'min', 'oct', 'ord', 'pow',
'round', and 'str' from the standard Python builtin module.
- Special security-aware versions of 'getattr' and 'hasattr',
-
+
- The Python 'string', 'math', and 'whrandom' modules, and
-
+
- A special function, 'test', that supports if-then expressions.
The 'test' function accepts any number of arguments. If the
first argument is true, then the second argument is returned,
@@ -406,10 +406,10 @@
argument is returned, and so on. If there is an odd number of
arguments, then the last argument is returned in the case that
none of the tested arguments is true, otherwise None is
- returned.
-
+ returned.
+
For example, to convert a value to lower case::
-
+
<dtml-var expr="title.lower()">
"""
@@ -447,7 +447,7 @@
result = result or {}
- # HACK - we precalculate all matches. Maybe we don't need them
+ # HACK - we precalculate all matches. Maybe we don't need them
# all. This should be fixed for performance issues
mo_p = parmre.match(text)
@@ -470,7 +470,7 @@
if parms.has_key(name):
if parms[name] is None: raise ParseError, (
'Attribute %s requires a value' % name, tag)
-
+
result[name] = parms[name]
else: raise ParseError, (
'Invalid attribute name, "%s"' % name, tag)
@@ -489,7 +489,7 @@
if not text or not text.strip():
return result
raise ParseError, ('invalid parameter: "%s"' % text, tag)
-
+
if not parms.has_key(name):
raise ParseError, ('Invalid attribute name, "%s"' % name, tag)
@@ -498,7 +498,7 @@
if type(p) is not ListType or p:
raise ParseError, (
'Duplicate values for attribute "%s"' % name, tag)
-
+
result[name] = value
text = text[l:].strip()
=== Zope3/src/zope/documenttemplate/dt_var.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/dt_var.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/dt_var.py Tue Dec 24 21:21:01 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
-#
+#
##############################################################################
"""Variable insertion parameters
@@ -59,7 +59,7 @@
- Cannot be formatted with the specified format, and
- - Are either the special Python value 'None' or
+ - Are either the special Python value 'None' or
are false and yield an empty string when converted to
a string.
@@ -90,12 +90,12 @@
value after formatting has been applied. These parameters
are supplied without arguments.
- 'lower' -- cause all upper-case letters to be converted to lower case.
+ 'lower' -- cause all upper-case letters to be converted to lower case.
- 'upper' -- cause all upper-case letters to be converted to lower case.
+ 'upper' -- cause all upper-case letters to be converted to lower case.
'capitalize' -- cause the first character of the inserted value
- to be converted to upper case.
+ to be converted to upper case.
'spacify' -- cause underscores in the inserted value to be
converted to spaces.
@@ -135,7 +135,7 @@
truncation, the value given for the 'etc' attribute is added to
the string. If the 'etc' attribute is not provided, then '...'
is used. For example, if the value of spam is
- '"blah blah blah blah"', then the tag
+ '"blah blah blah blah"', then the tag
'<!--#var spam size=10-->' inserts '"blah blah ..."'.
@@ -144,7 +144,7 @@
A 'call' tag is provided for evaluating named objects or expressions
without rendering the result.
-
+
$Id$
"""
from zope.documenttemplate.dt_util import parse_params, name_param, html_quote, str
@@ -152,7 +152,7 @@
from urllib import quote, quote_plus
-class Var:
+class Var:
name = 'var'
expr = None
@@ -166,7 +166,7 @@
url_quote_plus=1, missing='',
newline_to_br=1, url=1)
self.args = args
-
+
self.modifiers = tuple(
map(lambda t: t[1],
filter(lambda m, args=args, used=args.has_key:
@@ -281,7 +281,7 @@
__call__ = render
-class Call:
+class Call:
name = 'call'
expr = None
@@ -439,15 +439,15 @@
The 'comment' tag can be used to simply include comments
in DTML source.
-
+
For example::
-
+
<dtml-comment>
-
+
This text is not rendered.
</dtml-comment>
- '''
+ '''
name = 'comment'
blockContinuations = ()
=== Zope3/src/zope/documenttemplate/dt_with.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/dt_with.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/dt_with.py Tue Dec 24 21:21:01 2002
@@ -2,14 +2,14 @@
#
# Copyright (c) 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
-#
+#
##############################################################################
"""Nested namespace access
@@ -46,7 +46,7 @@
name = 'with'
mapping = None
only = 0
-
+
def __init__(self, blocks):
tname, args, section = blocks[0]
args = parse_params(args, name='', expr='', mapping=1, only=1)
=== Zope3/src/zope/documenttemplate/pdocumenttemplate.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/documenttemplate/pdocumenttemplate.py:1.1.2.1 Mon Dec 23 14:32:46 2002
+++ Zope3/src/zope/documenttemplate/pdocumenttemplate.py Tue Dec 24 21:21:01 2002
@@ -1,14 +1,14 @@
##############################################################################
#
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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
-#
+#
##############################################################################
"""Python implementations of document template some features
@@ -52,7 +52,7 @@
cache=self.cache
if cache.has_key(key):
return cache[key]
-
+
inst = self.self
if key[:1] == '_':
@@ -102,7 +102,7 @@
class DictInstance:
-
+
def __init__(self, mapping):
self.__d = mapping
@@ -111,7 +111,7 @@
return self.__d[name]
except KeyError:
raise AttributeError, name
-
+
class TemplateDict:
@@ -144,10 +144,10 @@
return v
def __len__(self):
- total = 0
- for d in self.dicts.dicts:
- total += len(d)
- return total
+ total = 0
+ for d in self.dicts.dicts:
+ total += len(d)
+ return total
def has_key(self,key):
try:
@@ -155,7 +155,7 @@
except KeyError:
return 0
return 1
-
+
getitem = __getitem__
def __call__(self, *args, **kw):