[ZPT] CVS: Zope27/lib/python/TAL - TALDefs.py:1.27.26.2 TALGenerator.py:1.54.26.3 TALInterpreter.py:1.68.26.4
Fred L. Drake, Jr.
fdrake@acm.org
Tue, 17 Sep 2002 16:18:22 -0400
Update of /cvs-repository/Zope27/lib/python/TAL
In directory cvs.zope.org:/tmp/cvs-serv10046/TAL
Modified Files:
Tag: Zope-2_7-development-branch
TALDefs.py TALGenerator.py TALInterpreter.py
Log Message:
Minor cleanups, removing TALDefs.quote().
=== Zope27/lib/python/TAL/TALDefs.py 1.27.26.1 => 1.27.26.2 ===
--- Zope27/lib/python/TAL/TALDefs.py:1.27.26.1 Tue Jul 30 16:12:52 2002
+++ Zope27/lib/python/TAL/TALDefs.py Tue Sep 17 16:18:21 2002
@@ -163,8 +163,3 @@
if opcode == "version":
return version
return None
-
-import cgi
-def quote(s, escape=cgi.escape):
- return '"%s"' % escape(s, 1)
-del cgi
=== Zope27/lib/python/TAL/TALGenerator.py 1.54.26.2 => 1.54.26.3 ===
--- Zope27/lib/python/TAL/TALGenerator.py:1.54.26.2 Thu Sep 5 16:58:08 2002
+++ Zope27/lib/python/TAL/TALGenerator.py Tue Sep 17 16:18:21 2002
@@ -162,7 +162,7 @@
if item[1] is None:
s = item[0]
else:
- s = "%s=%s" % (item[0], TALDefs.quote(item[1]))
+ s = '%s="%s"' % (item[0], cgi.escape(item[1], 1))
attrlist[i] = item[0], s
new.append(" " + s)
# if no non-optimizable attributes were found, convert to plain text
=== Zope27/lib/python/TAL/TALInterpreter.py 1.68.26.3 => 1.68.26.4 ===
--- Zope27/lib/python/TAL/TALInterpreter.py:1.68.26.3 Tue Sep 17 12:30:47 2002
+++ Zope27/lib/python/TAL/TALInterpreter.py Tue Sep 17 16:18:21 2002
@@ -23,7 +23,7 @@
# Do not use cStringIO here! It's not unicode aware. :(
from StringIO import StringIO
-from TALDefs import quote, TAL_VERSION, TALError, METALError
+from TALDefs import TAL_VERSION, TALError, METALError
from TALDefs import isCurrentVersion, getProgramVersion, getProgramMode
from TALGenerator import TALGenerator
from TranslationContext import TranslationContext
@@ -309,13 +309,13 @@
if value is None:
value = name
else:
- value = "%s=%s" % (name, quote(value))
+ value = '%s="%s"' % (name, escape(value, 1))
return 1, name, value
def attrAction_tal(self, item):
- name, value, action = item[:3]
- if action in ('metal', 'tal', 'xmlns', 'i18n'):
+ if item[2] in ('metal', 'tal', 'xmlns', 'i18n'):
return self.attrAction(item)
+ name, value, action = item[:3]
ok = 1
expr, msgid = item[3:]
if self.html and name.lower() in BOOLEAN_HTML_ATTRS:
@@ -327,31 +327,27 @@
value = None
else:
ok = 0
- else:
- if expr is not None:
- evalue = self.engine.evaluateText(item[3])
- if evalue is self.Default:
- if action == 'insert': # Cancelled insert
- ok = 0
- else:
- if evalue is None:
- ok = 0
- value = evalue
- if ok:
- if msgid:
- value = self.i18n_attribute(value)
- if value is None:
- value = name
- value = "%s=%s" % (name, quote(value))
+ elif expr is not None:
+ evalue = self.engine.evaluateText(item[3])
+ if evalue is self.Default:
+ if action == 'insert': # Cancelled insert
+ ok = 0
+ else:
+ if evalue is None:
+ ok = 0
+ value = evalue
+ if msgid:
+ value = self.i18n_attribute(value)
+ if value is None:
+ value = name
+ value = '%s="%s"' % (name, escape(value, 1))
return ok, name, value
+ bytecode_handlers["<attrAction>"] = attrAction
def i18n_attribute(self, s):
# s is the value of an attribute before translation
# it may have been computed
return self.translate(s, {})
-
-
- bytecode_handlers["<attrAction>"] = attrAction
def no_tag(self, start, program):
state = self.saveState()