Commit e052fb6b authored by Andreas Jung's avatar Andreas Jung

you're time has come, no longer needed for Z3 ZPTs

parent 1c0af142
TAL changes
This file contains change information for the current release.
Change information for previous versions can be found in the
file HISTORY.txt.
Version 1.5.0
Features Added
- Line and column numbers are added to more exceptions.
##############################################################################
#
# Copyright (c) 2001, 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.
#
##############################################################################
"""
Dummy TALES engine so that I can test out the TAL implementation.
"""
import re
import sys
from TALDefs import NAME_RE, TALESError, ErrorInfo
from ITALES import ITALESCompiler, ITALESEngine
from DocumentTemplate.DT_Util import ustr
class _Default:
pass
Default = _Default()
name_match = re.compile(r"(?s)(%s):(.*)\Z" % NAME_RE).match
class CompilerError(Exception):
pass
class DummyEngine:
position = None
source_file = None
__implements__ = ITALESCompiler, ITALESEngine
def __init__(self, macros=None):
if macros is None:
macros = {}
self.macros = macros
dict = {'nothing': None, 'default': Default}
self.locals = self.globals = dict
self.stack = [dict]
self.translationService = DummyTranslationService()
def getCompilerError(self):
return CompilerError
def getCompiler(self):
return self
def setSourceFile(self, source_file):
self.source_file = source_file
def setPosition(self, position):
self.position = position
def compile(self, expr):
return "$%s$" % expr
def uncompile(self, expression):
assert (expression.startswith("$") and expression.endswith("$"),
expression)
return expression[1:-1]
def beginScope(self):
self.stack.append(self.locals)
def endScope(self):
assert len(self.stack) > 1, "more endScope() than beginScope() calls"
self.locals = self.stack.pop()
def setLocal(self, name, value):
if self.locals is self.stack[-1]:
# Unmerge this scope's locals from previous scope of first set
self.locals = self.locals.copy()
self.locals[name] = value
def setGlobal(self, name, value):
self.globals[name] = value
def evaluate(self, expression):
assert (expression.startswith("$") and expression.endswith("$"),
expression)
expression = expression[1:-1]
m = name_match(expression)
if m:
type, expr = m.group(1, 2)
else:
type = "path"
expr = expression
if type in ("string", "str"):
return expr
if type in ("path", "var", "global", "local"):
return self.evaluatePathOrVar(expr)
if type == "not":
return not self.evaluate(expr)
if type == "exists":
return self.locals.has_key(expr) or self.globals.has_key(expr)
if type == "python":
try:
return eval(expr, self.globals, self.locals)
except:
raise TALESError("evaluation error in %s" % `expr`)
if type == "position":
# Insert the current source file name, line number,
# and column offset.
if self.position:
lineno, offset = self.position
else:
lineno, offset = None, None
return '%s (%s,%s)' % (self.source_file, lineno, offset)
raise TALESError("unrecognized expression: " + `expression`)
def evaluatePathOrVar(self, expr):
expr = expr.strip()
if self.locals.has_key(expr):
return self.locals[expr]
elif self.globals.has_key(expr):
return self.globals[expr]
else:
raise TALESError("unknown variable: %s" % `expr`)
def evaluateValue(self, expr):
return self.evaluate(expr)
def evaluateBoolean(self, expr):
return self.evaluate(expr)
def evaluateText(self, expr):
text = self.evaluate(expr)
if text is not None and text is not Default:
text = ustr(text)
return text
def evaluateStructure(self, expr):
# XXX Should return None or a DOM tree
return self.evaluate(expr)
def evaluateSequence(self, expr):
# XXX Should return a sequence
return self.evaluate(expr)
def evaluateMacro(self, macroName):
assert (macroName.startswith("$") and macroName.endswith("$"),
macroName)
macroName = macroName[1:-1]
file, localName = self.findMacroFile(macroName)
if not file:
# Local macro
macro = self.macros[localName]
else:
# External macro
import driver
program, macros = driver.compilefile(file)
macro = macros.get(localName)
if not macro:
raise TALESError("macro %s not found in file %s" %
(localName, file))
return macro
def findMacroDocument(self, macroName):
file, localName = self.findMacroFile(macroName)
if not file:
return file, localName
import driver
doc = driver.parsefile(file)
return doc, localName
def findMacroFile(self, macroName):
if not macroName:
raise TALESError("empty macro name")
i = macroName.rfind('/')
if i < 0:
# No slash -- must be a locally defined macro
return None, macroName
else:
# Up to last slash is the filename
fileName = macroName[:i]
localName = macroName[i+1:]
return fileName, localName
def setRepeat(self, name, expr):
seq = self.evaluateSequence(expr)
return Iterator(name, seq, self)
def createErrorInfo(self, err, position):
return ErrorInfo(err, position)
def getDefault(self):
return Default
def translate(self, domain, msgid, mapping, default=None):
return self.translationService.translate(domain, msgid, mapping,
default=default)
class Iterator:
# This is not an implementation of a Python iterator. The next()
# method returns true or false to indicate whether another item is
# available; if there is another item, the iterator instance calls
# setLocal() on the evaluation engine passed to the constructor.
def __init__(self, name, seq, engine):
self.name = name
self.seq = seq
self.engine = engine
self.nextIndex = 0
def next(self):
i = self.nextIndex
try:
item = self.seq[i]
except IndexError:
return 0
self.nextIndex = i+1
self.engine.setLocal(self.name, item)
return 1
class DummyDomain:
def translate(self, msgid, mapping=None, context=None,
target_language=None, default=None):
# This is a fake translation service which simply uppercases non
# ${name} placeholder text in the message id.
#
# First, transform a string with ${name} placeholders into a list of
# substrings. Then upcase everything but the placeholders, then glue
# things back together.
# simulate an unknown msgid by returning None
text = msgid
if msgid == "don't translate me":
if default is not None:
text = default
else:
text = msgid.upper()
def repl(m, mapping=mapping):
return ustr(mapping[m.group(m.lastindex).lower()])
cre = re.compile(r'\$(?:(%s)|\{(%s)\})' % (NAME_RE, NAME_RE))
return cre.sub(repl, text)
class DummyTranslationService:
def translate(self, domain, msgid, mapping=None, context=None,
target_language=None, default=None):
return self.getDomain(domain).translate(msgid, mapping, context,
target_language,
default=default)
def getDomain(self, domain):
return DummyDomain()
TAL history
This file contains change information for previous versions.
Change information for the current release can be found
in the file CHANGES.txt.
Version 1.4.0
Features Added
- Added TAL statement: omit_tag="[<boolean expr>]" replaces
the statement tag with its contents if the boolean
expression is true or omitted.
- The TAL and METAL namespaces can be applied to tag names,
tags in these namespaces are removed from rendered output
(leaving the contents in place, as with omit_tag)
whenever attributes in these namespaces would be, and
tag attributes without explicit namespaces default to the
tag's namespace (per XML spec).
Version 1.3.3
Bugs Fixed
- tal:atributes was creating stray attributes in METAL
expansion, and there was no unit test for this behavior.
- tal:attributes parsing was not catching badly malformed
values, and used "print" instead of raising exceptions.
Version 1.3.2
Features Added
- Adopted Zope-style CHANGES.txt and HISTORY.txt
- Improved execution performance
- Added simple ZPT vs. TAL vs. DTML benchmarks, run by markbench.py
Version 1.3.0
Features Added
- New builtin variable 'attrs'.
Bug Fixed
- Nested macros were not working correctly.
Version 1.2.0
Features Added
- The 'if' path modifier can cancel any TAL action.
Bug Fixed
- tal:attributes inserted empty attributes into source.
Version 1.1.0
Features Added
- TAL does not try to parse replacement structural text.
- Changed tests to match TAL's omitted attributes.
Version 1.0.0
- Various minor bugs fixed
Version 1.0.0b1
- All functionality described in the Project Wiki is implemented
This diff is collapsed.
"""Interface that a TALES engine provides to the METAL/TAL implementation."""
try:
from Interface import Interface
from Interface.Attribute import Attribute
except:
# Before 2.7
class Interface: pass
def Attribute(*args): pass
class ITALESCompiler(Interface):
"""Compile-time interface provided by a TALES implementation.
The TAL compiler needs an instance of this interface to support
compilation of TALES expressions embedded in documents containing
TAL and METAL constructs.
"""
def getCompilerError():
"""Return the exception class raised for compilation errors.
"""
def compile(expression):
"""Return a compiled form of 'expression' for later evaluation.
'expression' is the source text of the expression.
The return value may be passed to the various evaluate*()
methods of the ITALESEngine interface. No compatibility is
required for the values of the compiled expression between
different ITALESEngine implementations.
"""
class ITALESEngine(Interface):
"""Render-time interface provided by a TALES implementation.
The TAL interpreter uses this interface to TALES to support
evaluation of the compiled expressions returned by
ITALESCompiler.compile().
"""
def getCompiler():
"""Return an object that supports ITALESCompiler."""
def getDefault():
"""Return the value of the 'default' TALES expression.
Checking a value for a match with 'default' should be done
using the 'is' operator in Python.
"""
def setPosition((lineno, offset)):
"""Inform the engine of the current position in the source file.
This is used to allow the evaluation engine to report
execution errors so that site developers can more easily
locate the offending expression.
"""
def setSourceFile(filename):
"""Inform the engine of the name of the current source file.
This is used to allow the evaluation engine to report
execution errors so that site developers can more easily
locate the offending expression.
"""
def beginScope():
"""Push a new scope onto the stack of open scopes.
"""
def endScope():
"""Pop one scope from the stack of open scopes.
"""
def evaluate(compiled_expression):
"""Evaluate an arbitrary expression.
No constraints are imposed on the return value.
"""
def evaluateBoolean(compiled_expression):
"""Evaluate an expression that must return a Boolean value.
"""
def evaluateMacro(compiled_expression):
"""Evaluate an expression that must return a macro program.
"""
def evaluateStructure(compiled_expression):
"""Evaluate an expression that must return a structured
document fragment.
The result of evaluating 'compiled_expression' must be a
string containing a parsable HTML or XML fragment. Any TAL
markup cnotained in the result string will be interpreted.
"""
def evaluateText(compiled_expression):
"""Evaluate an expression that must return text.
The returned text should be suitable for direct inclusion in
the output: any HTML or XML escaping or quoting is the
responsibility of the expression itself.
"""
def evaluateValue(compiled_expression):
"""Evaluate an arbitrary expression.
No constraints are imposed on the return value.
"""
def createErrorInfo(exception, (lineno, offset)):
"""Returns an ITALESErrorInfo object.
The returned object is used to provide information about the
error condition for the on-error handler.
"""
def setGlobal(name, value):
"""Set a global variable.
The variable will be named 'name' and have the value 'value'.
"""
def setLocal(name, value):
"""Set a local variable in the current scope.
The variable will be named 'name' and have the value 'value'.
"""
def setRepeat(name, compiled_expression):
"""
"""
def translate(domain, msgid, mapping, default=None):
"""
See ITranslationService.translate()
"""
class ITALESErrorInfo(Interface):
type = Attribute("type",
"The exception class.")
value = Attribute("value",
"The exception instance.")
lineno = Attribute("lineno",
"The line number the error occurred on in the source.")
offset = Attribute("offset",
"The character offset at which the error occurred.")
TAL - Template Attribute Language
---------------------------------
This is an implementation of TAL, the Zope Template Attribute
Language. For TAL, see the Zope Presentation Templates ZWiki:
http://dev.zope.org/Wikis/DevSite/Projects/ZPT/FrontPage
It is not a Zope product nor is it designed exclusively to run inside
of Zope, but if you have a Zope checkout that includes
Products/ParsedXML, its Expat parser will be used.
Prerequisites
-------------
You need:
- A recent checkout of Zope2; don't forget to run the wo_pcgi.py
script to compile everything. (See above -- this is now optional.)
- A recent checkout of the Zope2 product ParsedXML, accessible
throught <Zope2>/lib/python/Products/ParsedXML; don't forget to run
the setup.py script to compiles Expat. (Again, optional.)
- Python 1.5.2; the driver script refuses to work with other versions
unless you specify the -n option; this is done so that I don't
accidentally use Python 2.x features.
- Create a .path file containing proper module search path; it should
point the <Zope2>/lib/python directory that you want to use.
How To Play
-----------
(Don't forget to edit .path, see above!)
The script driver.py takes an XML file with TAL markup as argument and
writes the expanded version to standard output. The filename argument
defaults to tests/input/test01.xml.
Regression test
---------------
There are unit test suites in the 'tests' subdirectory; these can be
run with tests/run.py. This should print the testcase names plus
progress info, followed by a final line saying "OK". It requires that
../unittest.py exists.
There are a number of test files in the 'tests' subdirectory, named
tests/input/test<number>.xml and tests/input/test<number>.html. The
Python script ./runtest.py calls driver.main() for each test file, and
should print "<file> OK" for each one. These tests are also run as
part of the unit test suites, so tests/run.py is all you need.
What's Here
-----------
DummyEngine.py simple-minded TALES execution engine
TALInterpreter.py class to interpret intermediate code
TALGenerator.py class to generate intermediate code
XMLParser.py base class to parse XML, avoiding DOM
TALParser.py class to parse XML with TAL into intermediate code
HTMLTALParser.py class to parse HTML with TAL into intermediate code
HTMLParser.py HTML-parsing base class
driver.py script to demonstrate TAL expansion
timer.py script to time various processing phases
setpath.py hack to set sys.path and import ZODB
__init__.py empty file that makes this directory a package
runtest.py Python script to run file-comparison tests
ndiff.py helper for runtest.py to produce diffs
tests/ drectory with test files and output
tests/run.py Python script to run all tests
Author and License
------------------
This code is written by Guido van Rossum (project lead), Fred Drake,
and Tim Peters. It is owned by Digital Creations and can be
redistributed under the Zope Public License.
TO DO
-----
(See also http://www.zope.org/Members/jim/ZPTIssueTracker .)
- Need to remove leading whitespace and newline when omitting an
element (either through tal:replace with a value of nothing or
tal:condition with a false condition).
- Empty TAL/METAL attributes are ignored: tal:replace="" is ignored
rather than causing an error.
- HTMLTALParser.py and TALParser.py are silly names. Should be
HTMLTALCompiler.py and XMLTALCompiler.py (or maybe shortened,
without "TAL"?)
- Should we preserve case of tags and attribute names in HTML?
##############################################################################
#
# Copyright (c) 2001, 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.
#
##############################################################################
"""
Common definitions used by TAL and METAL compilation an transformation.
"""
from types import ListType, TupleType
from ITALES import ITALESErrorInfo
TAL_VERSION = "1.5"
XML_NS = "http://www.w3.org/XML/1998/namespace" # URI for XML namespace
XMLNS_NS = "http://www.w3.org/2000/xmlns/" # URI for XML NS declarations
ZOPE_TAL_NS = "http://xml.zope.org/namespaces/tal"
ZOPE_METAL_NS = "http://xml.zope.org/namespaces/metal"
ZOPE_I18N_NS = "http://xml.zope.org/namespaces/i18n"
# This RE must exactly match the expression of the same name in the
# zope.i18n.simpletranslationservice module:
NAME_RE = "[a-zA-Z_][-a-zA-Z0-9_]*"
KNOWN_METAL_ATTRIBUTES = [
"define-macro",
"use-macro",
"define-slot",
"fill-slot",
"slot",
]
KNOWN_TAL_ATTRIBUTES = [
"define",
"condition",
"content",
"replace",
"repeat",
"attributes",
"on-error",
"omit-tag",
"tal tag",
]
KNOWN_I18N_ATTRIBUTES = [
"translate",
"domain",
"target",
"source",
"attributes",
"data",
"name",
]
class TALError(Exception):
def __init__(self, msg, position=(None, None)):
assert msg != ""
self.msg = msg
self.lineno = position[0]
self.offset = position[1]
self.filename = None
def setFile(self, filename):
self.filename = filename
def __str__(self):
result = self.msg
if self.lineno is not None:
result = result + ", at line %d" % self.lineno
if self.offset is not None:
result = result + ", column %d" % (self.offset + 1)
if self.filename is not None:
result = result + ', in file %s' % self.filename
return result
class METALError(TALError):
pass
class TALESError(TALError):
pass
class I18NError(TALError):
pass
class ErrorInfo:
__implements__ = ITALESErrorInfo
def __init__(self, err, position=(None, None)):
if isinstance(err, Exception):
self.type = err.__class__
self.value = err
else:
self.type = err
self.value = None
self.lineno = position[0]
self.offset = position[1]
import re
_attr_re = re.compile(r"\s*([^\s]+)\s+([^\s].*)\Z", re.S)
_subst_re = re.compile(r"\s*(?:(text|structure)\s+)?(.*)\Z", re.S)
del re
def parseAttributeReplacements(arg, xml):
dict = {}
for part in splitParts(arg):
m = _attr_re.match(part)
if not m:
raise TALError("Bad syntax in attributes: " + `part`)
name, expr = m.group(1, 2)
if not xml:
name = name.lower()
if dict.has_key(name):
raise TALError("Duplicate attribute name in attributes: " + `part`)
dict[name] = expr
return dict
def parseSubstitution(arg, position=(None, None)):
m = _subst_re.match(arg)
if not m:
raise TALError("Bad syntax in substitution text: " + `arg`, position)
key, expr = m.group(1, 2)
if not key:
key = "text"
return key, expr
def splitParts(arg):
# Break in pieces at undoubled semicolons and
# change double semicolons to singles:
arg = arg.replace(";;", "\0")
parts = arg.split(';')
parts = [p.replace("\0", ";") for p in parts]
if len(parts) > 1 and not parts[-1].strip():
del parts[-1] # It ended in a semicolon
return parts
def isCurrentVersion(program):
version = getProgramVersion(program)
return version == TAL_VERSION
def getProgramMode(program):
version = getProgramVersion(program)
if (version == TAL_VERSION and isinstance(program[1], TupleType) and
len(program[1]) == 2):
opcode, mode = program[1]
if opcode == "mode":
return mode
return None
def getProgramVersion(program):
if (len(program) >= 2 and
isinstance(program[0], TupleType) and len(program[0]) == 2):
opcode, version = program[0]
if opcode == "version":
return version
return None
import re
_ent1_re = re.compile('&(?![A-Z#])', re.I)
_entch_re = re.compile('&([A-Z][A-Z0-9]*)(?![A-Z0-9;])', re.I)
_entn1_re = re.compile('&#(?![0-9X])', re.I)
_entnx_re = re.compile('&(#X[A-F0-9]*)(?![A-F0-9;])', re.I)
_entnd_re = re.compile('&(#[0-9][0-9]*)(?![0-9;])')
del re
def attrEscape(s):
"""Replace special characters '&<>' by character entities,
except when '&' already begins a syntactically valid entity."""
s = _ent1_re.sub('&amp;', s)
s = _entch_re.sub(r'&amp;\1', s)
s = _entn1_re.sub('&amp;#', s)
s = _entnx_re.sub(r'&amp;\1', s)
s = _entnd_re.sub(r'&amp;\1', s)
s = s.replace('<', '&lt;')
s = s.replace('>', '&gt;')
s = s.replace('"', '&quot;')
return s
This diff is collapsed.
This diff is collapsed.
##############################################################################
#
# Copyright (c) 2001, 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.
#
##############################################################################
"""
Parse XML and compile to TALInterpreter intermediate code.
"""
from XMLParser import XMLParser
from TALDefs import XML_NS, ZOPE_I18N_NS, ZOPE_METAL_NS, ZOPE_TAL_NS
from TALGenerator import TALGenerator
class TALParser(XMLParser):
ordered_attributes = 1
def __init__(self, gen=None): # Override
XMLParser.__init__(self)
if gen is None:
gen = TALGenerator()
self.gen = gen
self.nsStack = []
self.nsDict = {XML_NS: 'xml'}
self.nsNew = []
def getCode(self):
return self.gen.getCode()
def getWarnings(self):
return ()
def StartNamespaceDeclHandler(self, prefix, uri):
self.nsStack.append(self.nsDict.copy())
self.nsDict[uri] = prefix
self.nsNew.append((prefix, uri))
def EndNamespaceDeclHandler(self, prefix):
self.nsDict = self.nsStack.pop()
def StartElementHandler(self, name, attrs):
if self.ordered_attributes:
# attrs is a list of alternating names and values
attrlist = []
for i in range(0, len(attrs), 2):
key = attrs[i]
value = attrs[i+1]
attrlist.append((key, value))
else:
# attrs is a dict of {name: value}
attrlist = attrs.items()
attrlist.sort() # For definiteness
name, attrlist, taldict, metaldict, i18ndict \
= self.process_ns(name, attrlist)
attrlist = self.xmlnsattrs() + attrlist
self.gen.emitStartElement(name, attrlist, taldict, metaldict, i18ndict)
def process_ns(self, name, attrlist):
taldict = {}
metaldict = {}
i18ndict = {}
fixedattrlist = []
name, namebase, namens = self.fixname(name)
for key, value in attrlist:
key, keybase, keyns = self.fixname(key)
ns = keyns or namens # default to tag namespace
item = key, value
if ns == 'metal':
metaldict[keybase] = value
item = item + ("metal",)
elif ns == 'tal':
taldict[keybase] = value
item = item + ("tal",)
elif ns == 'i18n':
i18ndict[keybase] = value
item = item + ('i18n',)
fixedattrlist.append(item)
if namens in ('metal', 'tal', 'i18n'):
taldict['tal tag'] = namens
return name, fixedattrlist, taldict, metaldict, i18ndict
def xmlnsattrs(self):
newlist = []
for prefix, uri in self.nsNew:
if prefix:
key = "xmlns:" + prefix
else:
key = "xmlns"
if uri in (ZOPE_METAL_NS, ZOPE_TAL_NS, ZOPE_I18N_NS):
item = (key, uri, "xmlns")
else:
item = (key, uri)
newlist.append(item)
self.nsNew = []
return newlist
def fixname(self, name):
if ' ' in name:
uri, name = name.split(' ')
prefix = self.nsDict[uri]
prefixed = name
if prefix:
prefixed = "%s:%s" % (prefix, name)
ns = 'x'
if uri == ZOPE_TAL_NS:
ns = 'tal'
elif uri == ZOPE_METAL_NS:
ns = 'metal'
elif uri == ZOPE_I18N_NS:
ns = 'i18n'
return (prefixed, name, ns)
return (name, name, None)
def EndElementHandler(self, name):
name = self.fixname(name)[0]
self.gen.emitEndElement(name)
def DefaultHandler(self, text):
self.gen.emitRawText(text)
def test():
import sys
p = TALParser()
file = "tests/input/test01.xml"
if sys.argv[1:]:
file = sys.argv[1]
p.parseFile(file)
program, macros = p.getCode()
from TALInterpreter import TALInterpreter
from DummyEngine import DummyEngine
engine = DummyEngine(macros)
TALInterpreter(program, macros, engine, sys.stdout, wrap=0)()
if __name__ == "__main__":
test()
##############################################################################
#
# Copyright (c) 2001, 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.
#
##############################################################################
"""Translation context object for the TALInterpreter's I18N support.
The translation context provides a container for the information
needed to perform translation of a marked string from a page template.
$Id$
"""
DEFAULT_DOMAIN = "default"
class TranslationContext:
"""Information about the I18N settings of a TAL processor."""
def __init__(self, parent=None, domain=None, target=None, source=None):
if parent:
if not domain:
domain = parent.domain
if not target:
target = parent.target
if not source:
source = parent.source
elif domain is None:
domain = DEFAULT_DOMAIN
self.parent = parent
self.domain = domain
self.target = target
self.source = source
##############################################################################
#
# Copyright (c) 2001, 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
#
##############################################################################
"""
Generic expat-based XML parser base class.
"""
import xml.parsers.expat
import zLOG
XMLParseError = xml.parsers.expat.ExpatError
class XMLParser:
ordered_attributes = 0
handler_names = [
"StartElementHandler",
"EndElementHandler",
"ProcessingInstructionHandler",
"CharacterDataHandler",
"UnparsedEntityDeclHandler",
"NotationDeclHandler",
"StartNamespaceDeclHandler",
"EndNamespaceDeclHandler",
"CommentHandler",
"StartCdataSectionHandler",
"EndCdataSectionHandler",
"DefaultHandler",
"DefaultHandlerExpand",
"NotStandaloneHandler",
"ExternalEntityRefHandler",
"XmlDeclHandler",
"StartDoctypeDeclHandler",
"EndDoctypeDeclHandler",
"ElementDeclHandler",
"AttlistDeclHandler"
]
def __init__(self, encoding=None):
self.parser = p = self.createParser()
if self.ordered_attributes:
try:
self.parser.ordered_attributes = self.ordered_attributes
except AttributeError:
zLOG.LOG("TAL.XMLParser", zLOG.INFO,
"Can't set ordered_attributes")
self.ordered_attributes = 0
for name in self.handler_names:
method = getattr(self, name, None)
if method is not None:
try:
setattr(p, name, method)
except AttributeError:
zLOG.LOG("TAL.XMLParser", zLOG.PROBLEM,
"Can't set expat handler %s" % name)
def createParser(self, encoding=None):
return xml.parsers.expat.ParserCreate(encoding, ' ')
def parseFile(self, filename):
self.parseStream(open(filename))
def parseString(self, s):
self.parser.Parse(s, 1)
def parseURL(self, url):
import urllib
self.parseStream(urllib.urlopen(url))
def parseStream(self, stream):
self.parser.ParseFile(stream)
def parseFragment(self, s, end=0):
self.parser.Parse(s, end)
##############################################################################
#
# Copyright (c) 2001, 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
#
##############################################################################
""" Template Attribute Language package """
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<dtml-in r8>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
</dtml-in>
<dtml-in r8>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
</dtml-in>
<dtml-in r2>
<dtml-in r2>
<dtml-in r2>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
</dtml-in>
</dtml-in>
</dtml-in>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
<dtml-in r64>
<td bgcolor="white">&dtml-x0;</td>
<td bgcolor="white">&dtml-x1;</td>
<td bgcolor="white">&dtml-x2;</td>
<td bgcolor="white">&dtml-x3;</td>
<td bgcolor="white">&dtml-x4;</td>
<td bgcolor="white">&dtml-x5;</td>
<td bgcolor="white">&dtml-x6;</td>
<td bgcolor="white">&dtml-x7;</td>
</dtml-in>
<dtml-in r64>
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
</dtml-in>
<dtml-in r64>
<td bgcolor="white">&dtml-x0;</td>
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
</dtml-in>
<dtml-in r8>
<dtml-let y0=x0 y1=x1 y2=x2 y3=x3 y4=x4 y5=x5 y6=x6 y7=x7>
<td bgcolor="white">&dtml-y0;</td>
<td bgcolor="white">&dtml-y1;</td>
<td bgcolor="white">&dtml-y2;</td>
<td bgcolor="white">&dtml-y3;</td>
<td bgcolor="white">&dtml-y4;</td>
<td bgcolor="white">&dtml-y5;</td>
<td bgcolor="white">&dtml-y6;</td>
<td bgcolor="white">&dtml-y7;</td>
</dtml-let>
</dtml-in>
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
<td bgcolor="white" tal:content="x4"></td>
<td bgcolor="white" tal:content="x5"></td>
<td bgcolor="white" tal:content="x6"></td>
<td bgcolor="white" tal:content="x7"></td>
<dtml-in tal:repeat="r r8">
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
</dtml-in>
<dtml-in tal:repeat="r r8">
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
<td bgcolor="white" tal:content="x4"></td>
<td bgcolor="white" tal:content="x5"></td>
<td bgcolor="white" tal:content="x6"></td>
<td bgcolor="white" tal:content="x7"></td>
</dtml-in>
<dtml-in tal:repeat="r r2">
<dtml-in tal:repeat="r r2">
<dtml-in tal:repeat="r r2">
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
<td bgcolor="white" tal:content="x4"></td>
<td bgcolor="white" tal:content="x5"></td>
<td bgcolor="white" tal:content="x6"></td>
<td bgcolor="white" tal:content="x7"></td>
</dtml-in>
</dtml-in>
</dtml-in>
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
<td bgcolor="white" tal:content="x4"></td>
<td bgcolor="white" tal:content="x5"></td>
<td bgcolor="white" tal:content="x6"></td>
<td bgcolor="white" tal:content="x7"></td>
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
<td bgcolor="white" tal:content="x4"></td>
<td bgcolor="white" tal:content="x5"></td>
<td bgcolor="white" tal:content="x6"></td>
<td bgcolor="white" tal:content="x7"></td>
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
<td bgcolor="white" tal:content="x4"></td>
<td bgcolor="white" tal:content="x5"></td>
<td bgcolor="white" tal:content="x6"></td>
<td bgcolor="white" tal:content="x7"></td>
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
<td bgcolor="white" tal:content="x4"></td>
<td bgcolor="white" tal:content="x5"></td>
<td bgcolor="white" tal:content="x6"></td>
<td bgcolor="white" tal:content="x7"></td>
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
<td bgcolor="white" tal:content="x4"></td>
<td bgcolor="white" tal:content="x5"></td>
<td bgcolor="white" tal:content="x6"></td>
<td bgcolor="white" tal:content="x7"></td>
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
<td bgcolor="white" tal:content="x4"></td>
<td bgcolor="white" tal:content="x5"></td>
<td bgcolor="white" tal:content="x6"></td>
<td bgcolor="white" tal:content="x7"></td>
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
<td bgcolor="white" tal:content="x4"></td>
<td bgcolor="white" tal:content="x5"></td>
<td bgcolor="white" tal:content="x6"></td>
<td bgcolor="white" tal:content="x7"></td>
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
<td bgcolor="white" tal:content="x4"></td>
<td bgcolor="white" tal:content="x5"></td>
<td bgcolor="white" tal:content="x6"></td>
<td bgcolor="white" tal:content="x7"></td>
<td bgcolor="white"><span tal:replace="x0"></span></td>
<td bgcolor="white"><span tal:replace="x1"></span></td>
<td bgcolor="white"><span tal:replace="x2"></span></td>
<td bgcolor="white"><span tal:replace="x3"></span></td>
<td bgcolor="white"><span tal:replace="x4"></span></td>
<td bgcolor="white"><span tal:replace="x5"></span></td>
<td bgcolor="white"><span tal:replace="x6"></span></td>
<td bgcolor="white"><span tal:replace="x7"></span></td>
<td bgcolor="white"><span tal:replace="x0"></span></td>
<td bgcolor="white"><span tal:replace="x1"></span></td>
<td bgcolor="white"><span tal:replace="x2"></span></td>
<td bgcolor="white"><span tal:replace="x3"></span></td>
<td bgcolor="white"><span tal:replace="x4"></span></td>
<td bgcolor="white"><span tal:replace="x5"></span></td>
<td bgcolor="white"><span tal:replace="x6"></span></td>
<td bgcolor="white"><span tal:replace="x7"></span></td>
<td bgcolor="white"><span tal:replace="x0"></span></td>
<td bgcolor="white"><span tal:replace="x1"></span></td>
<td bgcolor="white"><span tal:replace="x2"></span></td>
<td bgcolor="white"><span tal:replace="x3"></span></td>
<td bgcolor="white"><span tal:replace="x4"></span></td>
<td bgcolor="white"><span tal:replace="x5"></span></td>
<td bgcolor="white"><span tal:replace="x6"></span></td>
<td bgcolor="white"><span tal:replace="x7"></span></td>
<td bgcolor="white"><span tal:replace="x0"></span></td>
<td bgcolor="white"><span tal:replace="x1"></span></td>
<td bgcolor="white"><span tal:replace="x2"></span></td>
<td bgcolor="white"><span tal:replace="x3"></span></td>
<td bgcolor="white"><span tal:replace="x4"></span></td>
<td bgcolor="white"><span tal:replace="x5"></span></td>
<td bgcolor="white"><span tal:replace="x6"></span></td>
<td bgcolor="white"><span tal:replace="x7"></span></td>
<td bgcolor="white"><span tal:replace="x0"></span></td>
<td bgcolor="white"><span tal:replace="x1"></span></td>
<td bgcolor="white"><span tal:replace="x2"></span></td>
<td bgcolor="white"><span tal:replace="x3"></span></td>
<td bgcolor="white"><span tal:replace="x4"></span></td>
<td bgcolor="white"><span tal:replace="x5"></span></td>
<td bgcolor="white"><span tal:replace="x6"></span></td>
<td bgcolor="white"><span tal:replace="x7"></span></td>
<td bgcolor="white"><span tal:replace="x0"></span></td>
<td bgcolor="white"><span tal:replace="x1"></span></td>
<td bgcolor="white"><span tal:replace="x2"></span></td>
<td bgcolor="white"><span tal:replace="x3"></span></td>
<td bgcolor="white"><span tal:replace="x4"></span></td>
<td bgcolor="white"><span tal:replace="x5"></span></td>
<td bgcolor="white"><span tal:replace="x6"></span></td>
<td bgcolor="white"><span tal:replace="x7"></span></td>
<td bgcolor="white"><span tal:replace="x0"></span></td>
<td bgcolor="white"><span tal:replace="x1"></span></td>
<td bgcolor="white"><span tal:replace="x2"></span></td>
<td bgcolor="white"><span tal:replace="x3"></span></td>
<td bgcolor="white"><span tal:replace="x4"></span></td>
<td bgcolor="white"><span tal:replace="x5"></span></td>
<td bgcolor="white"><span tal:replace="x6"></span></td>
<td bgcolor="white"><span tal:replace="x7"></span></td>
<td bgcolor="white"><span tal:replace="x0"></span></td>
<td bgcolor="white"><span tal:replace="x1"></span></td>
<td bgcolor="white"><span tal:replace="x2"></span></td>
<td bgcolor="white"><span tal:replace="x3"></span></td>
<td bgcolor="white"><span tal:replace="x4"></span></td>
<td bgcolor="white"><span tal:replace="x5"></span></td>
<td bgcolor="white"><span tal:replace="x6"></span></td>
<td bgcolor="white"><span tal:replace="x7"></span></td>
<dtml-in tal:repeat="r r64">
<td bgcolor="white" tal:content="x0"></td>
<td bgcolor="white" tal:content="x1"></td>
<td bgcolor="white" tal:content="x2"></td>
<td bgcolor="white" tal:content="x3"></td>
<td bgcolor="white" tal:content="x4"></td>
<td bgcolor="white" tal:content="x5"></td>
<td bgcolor="white" tal:content="x6"></td>
<td bgcolor="white" tal:content="x7"></td>
</dtml-in>
<dtml-in tal:repeat="r r64">
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
</dtml-in>
<dtml-in tal:repeat="r r64">
<td bgcolor="white" tal:content="x0"></td>
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
A large chunk of text to be repeated.
</dtml-in>
<dtml-in tal:repeat="r r8">
<span tal:define="y0 x0;y1 x1;y2 x2;y3 x3;y4 x4;y5 x5;y6 x6;y7 x7">
<td bgcolor="white" tal:content="y0"></td>
<td bgcolor="white" tal:content="y1"></td>
<td bgcolor="white" tal:content="y2"></td>
<td bgcolor="white" tal:content="y3"></td>
<td bgcolor="white" tal:content="y4"></td>
<td bgcolor="white" tal:content="y5"></td>
<td bgcolor="white" tal:content="y6"></td>
<td bgcolor="white" tal:content="y7"></td>
</span>
</dtml-in>
#!/usr/bin/env python
##############################################################################
#
# Copyright (c) 2001, 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.
#
##############################################################################
"""
Driver program to test METAL and TAL implementation.
Usage: driver.py [options] [file]
Options:
-h / --help
Print this message and exit.
-H / --html
-x / --xml
Explicitly choose HTML or XML input. The default is to automatically
select based on the file extension. These options are mutually
exclusive.
-l
Lenient structure insertion.
-m
Macro expansion only
-s
Print intermediate opcodes only
-t
Leave TAL/METAL attributes in output
-i
Leave I18N substitution strings un-interpolated.
"""
import os
import sys
import getopt
if __name__ == "__main__":
import setpath # Local hack to tweak sys.path etc.
# Import local classes
import TALDefs
from DummyEngine import DummyEngine
from DummyEngine import DummyTranslationService
FILE = "tests/input/test01.xml"
class TestTranslations(DummyTranslationService):
def translate(self, domain, msgid, mapping=None, context=None,
target_language=None, default=None):
if msgid == 'timefmt':
return '%(minutes)s minutes after %(hours)s %(ampm)s' % mapping
elif msgid == 'jobnum':
return '%(jobnum)s is the JOB NUMBER' % mapping
elif msgid == 'verify':
s = 'Your contact email address is recorded as %(email)s'
return s % mapping
elif msgid == 'mailto:${request/submitter}':
return 'mailto:bperson@dom.ain'
elif msgid == 'origin':
return '%(name)s was born in %(country)s' % mapping
return DummyTranslationService.translate(self, domain, msgid,
mapping, context,
target_language,
default=default)
class TestEngine(DummyEngine):
def __init__(self, macros=None):
DummyEngine.__init__(self, macros)
self.translationService = TestTranslations()
def evaluatePathOrVar(self, expr):
if expr == 'here/currentTime':
return {'hours' : 6,
'minutes': 59,
'ampm' : 'PM',
}
elif expr == 'context/@@object_name':
return '7'
elif expr == 'request/submitter':
return 'aperson@dom.ain'
return DummyEngine.evaluatePathOrVar(self, expr)
# This is a disgusting hack so that we can use engines that actually know
# something about certain object paths. TimeEngine knows about
# here/currentTime.
ENGINES = {'test23.html': TestEngine,
'test24.html': TestEngine,
'test26.html': TestEngine,
'test27.html': TestEngine,
'test28.html': TestEngine,
'test29.html': TestEngine,
'test30.html': TestEngine,
'test31.html': TestEngine,
'test32.html': TestEngine,
}
def usage(code, msg=''):
# Python 2.1 required
print >> sys.stderr, __doc__
if msg:
print >> sys.stderr, msg
sys.exit(code)
def main():
macros = 0
mode = None
showcode = 0
showtal = -1
strictinsert = 1
i18nInterpolate = 1
try:
opts, args = getopt.getopt(sys.argv[1:], "hHxlmsti",
['help', 'html', 'xml'])
except getopt.error, msg:
usage(2, msg)
for opt, arg in opts:
if opt in ('-h', '--help'):
usage(0)
if opt in ('-H', '--html'):
if mode == 'xml':
usage(1, '--html and --xml are mutually exclusive')
mode = "html"
if opt == '-l':
strictinsert = 0
if opt == '-m':
macros = 1
if opt == '-n':
versionTest = 0
if opt in ('-x', '--xml'):
if mode == 'html':
usage(1, '--html and --xml are mutually exclusive')
mode = "xml"
if opt == '-s':
showcode = 1
if opt == '-t':
showtal = 1
if opt == '-i':
i18nInterpolate = 0
if args:
file = args[0]
else:
file = FILE
it = compilefile(file, mode)
if showcode:
showit(it)
else:
# See if we need a special engine for this test
engine = None
engineClass = ENGINES.get(os.path.basename(file))
if engineClass is not None:
engine = engineClass(macros)
interpretit(it, engine=engine,
tal=(not macros), showtal=showtal,
strictinsert=strictinsert,
i18nInterpolate=i18nInterpolate)
def interpretit(it, engine=None, stream=None, tal=1, showtal=-1,
strictinsert=1, i18nInterpolate=1):
from TALInterpreter import TALInterpreter
program, macros = it
assert TALDefs.isCurrentVersion(program)
if engine is None:
engine = DummyEngine(macros)
TALInterpreter(program, macros, engine, stream, wrap=0,
tal=tal, showtal=showtal, strictinsert=strictinsert,
i18nInterpolate=i18nInterpolate)()
def compilefile(file, mode=None):
assert mode in ("html", "xml", None)
if mode is None:
ext = os.path.splitext(file)[1]
if ext.lower() in (".html", ".htm"):
mode = "html"
else:
mode = "xml"
if mode == "html":
from HTMLTALParser import HTMLTALParser
p = HTMLTALParser()
else:
from TALParser import TALParser
p = TALParser()
p.parseFile(file)
return p.getCode()
def showit(it):
from pprint import pprint
pprint(it)
if __name__ == "__main__":
main()
#! /usr/bin/env python
# This software is subject to the provisions of the Zope Public License,
# Version 1.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.
'''Run benchmarks of TAL vs. DTML'''
try:
import warnings
except ImportError:
pass
else:
warnings.filterwarnings("ignore", category=DeprecationWarning)
import os
os.environ['NO_SECURITY'] = 'true'
import sys, time
if __name__ == "__main__":
import setpath
from DocumentTemplate.DT_HTML import HTMLFile
from HTMLTALParser import HTMLTALParser
from TALInterpreter import TALInterpreter
from DummyEngine import DummyEngine
from cStringIO import StringIO
def time_apply(f, args, kwargs, count):
for i in range(4):
f(*args, **kwargs)
r = [None] * count
t0 = time.clock()
for i in r:
pass
t1 = time.clock()
for i in r:
f(*args, **kwargs)
t = time.clock() - t1 - (t1 - t0)
return t / count
def time_zpt(fn, count):
from Products.PageTemplates.PageTemplate import PageTemplate
pt = PageTemplate()
pt.write(open(fn).read())
return time_apply(pt.pt_render, (), {'extra_context': data}, count)
def time_tal(fn, count):
p = HTMLTALParser()
p.parseFile(fn)
program, macros = p.getCode()
engine = DummyEngine(macros)
engine.globals = data
tal = TALInterpreter(program, macros, engine, StringIO(), wrap=0,
tal=1, strictinsert=0)
return time_apply(tal, (), {}, count)
def time_dtml(fn, count):
html = HTMLFile(fn)
return time_apply(html, (), data, count)
def profile_zpt(fn, count, profiler):
from Products.PageTemplates.PageTemplate import PageTemplate
pt = PageTemplate()
pt.write(open(fn).read())
for i in range(4):
pt.pt_render(extra_context=data)
r = [None] * count
for i in r:
profiler.runcall(pt.pt_render, 0, data)
def profile_tal(fn, count, profiler):
p = HTMLTALParser()
p.parseFile(fn)
program, macros = p.getCode()
engine = DummyEngine(macros)
engine.globals = data
tal = TALInterpreter(program, macros, engine, StringIO(), wrap=0,
tal=1, strictinsert=0)
for i in range(4):
tal()
r = [None] * count
for i in r:
profiler.runcall(tal)
tal_fn = 'benchmark/tal%.2d.html'
dtml_fn = 'benchmark/dtml%.2d.html'
def compare(n, count, profiler=None):
t1 = int(time_zpt(tal_fn % n, count) * 1000 + 0.5)
t2 = int(time_tal(tal_fn % n, count) * 1000 + 0.5)
t3 = int(time_dtml(dtml_fn % n, count) * 1000 + 0.5)
print '%.2d: %10s %10s %10s' % (n, t1, t2, t3)
if profiler:
profile_tal(tal_fn % n, count, profiler)
def main(count, profiler=None):
n = 1
print '##: %10s %10s %10s' % ('ZPT', 'TAL', 'DTML')
while os.path.isfile(tal_fn % n) and os.path.isfile(dtml_fn % n):
compare(n, count, profiler)
n = n + 1
data = {'x':'X', 'r2': range(2), 'r8': range(8), 'r64': range(64)}
for i in range(10):
data['x%s' % i] = 'X%s' % i
if __name__ == "__main__":
filename = "markbench.prof"
profiler = None
if len(sys.argv) > 1 and sys.argv[1] == "-p":
import profile
profiler = profile.Profile()
del sys.argv[1]
if len(sys.argv) > 1:
for arg in sys.argv[1:]:
compare(int(arg), 25, profiler)
else:
main(25, profiler)
if profiler is not None:
profiler.dump_stats(filename)
import pstats
p = pstats.Stats(filename)
p.strip_dirs()
p.sort_stats('time', 'calls')
try:
p.print_stats(20)
except IOError, e:
if e.errno != errno.EPIPE:
raise
This diff is collapsed.
This diff is collapsed.
#! /usr/bin/env python
##############################################################################
#
# Copyright (c) 2001, 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
#
##############################################################################
"""
Driver program to run METAL and TAL regression tests.
"""
import sys
import os
from cStringIO import StringIO
import glob
import traceback
if __name__ == "__main__":
import setpath # Local hack to tweak sys.path etc.
import driver
import tests.utils
def showdiff(a, b):
import ndiff
cruncher = ndiff.SequenceMatcher(ndiff.IS_LINE_JUNK, a, b)
for tag, alo, ahi, blo, bhi in cruncher.get_opcodes():
if tag == "equal":
continue
print nicerange(alo, ahi) + tag[0] + nicerange(blo, bhi)
ndiff.dump('<', a, alo, ahi)
if a and b:
print '---'
ndiff.dump('>', b, blo, bhi)
def nicerange(lo, hi):
if hi <= lo+1:
return str(lo+1)
else:
return "%d,%d" % (lo+1, hi)
def main():
opts = []
args = sys.argv[1:]
quiet = 0
unittesting = 0
if args and args[0] == "-q":
quiet = 1
del args[0]
if args and args[0] == "-Q":
unittesting = 1
del args[0]
while args and args[0].startswith('-'):
opts.append(args[0])
del args[0]
if not args:
prefix = os.path.join("tests", "input", "test*.")
if tests.utils.skipxml:
xmlargs = []
else:
xmlargs = glob.glob(prefix + "xml")
xmlargs.sort()
htmlargs = glob.glob(prefix + "html")
htmlargs.sort()
args = xmlargs + htmlargs
if not args:
sys.stderr.write("No tests found -- please supply filenames\n")
sys.exit(1)
errors = 0
for arg in args:
locopts = []
if arg.find("metal") >= 0 and "-m" not in opts:
locopts.append("-m")
if not unittesting:
print arg,
sys.stdout.flush()
if tests.utils.skipxml and arg.endswith(".xml"):
print "SKIPPED (XML parser not available)"
continue
save = sys.stdout, sys.argv
try:
try:
sys.stdout = stdout = StringIO()
sys.argv = [""] + opts + locopts + [arg]
driver.main()
finally:
sys.stdout, sys.argv = save
except SystemExit:
raise
except:
errors = 1
if quiet:
print sys.exc_type
sys.stdout.flush()
else:
if unittesting:
print
else:
print "Failed:"
sys.stdout.flush()
traceback.print_exc()
continue
head, tail = os.path.split(arg)
outfile = os.path.join(
head.replace("input", "output"),
tail)
try:
f = open(outfile)
except IOError:
expected = None
print "(missing file %s)" % outfile,
else:
expected = f.readlines()
f.close()
stdout.seek(0)
if hasattr(stdout, "readlines"):
actual = stdout.readlines()
else:
actual = readlines(stdout)
if actual == expected:
if not unittesting:
print "OK"
else:
if unittesting:
print
else:
print "not OK"
errors = 1
if not quiet and expected is not None:
showdiff(expected, actual)
if errors:
sys.exit(1)
def readlines(f):
L = []
while 1:
line = f.readline()
if not line:
break
L.append(line)
return L
if __name__ == "__main__":
main()
# This software is subject to the provisions of the Zope Public License,
# Version 1.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.
"""
Read a module search path from .path.
"""
import os
import sys
dir = os.path.dirname(__file__)
path = os.path.join(dir, ".path")
try:
f = open(path)
except IOError:
raise IOError, "Please edit .path to point to <Zope2/lib/python>"
else:
for line in f.readlines():
line = line.strip()
if line and line[0] != '#':
for dir in line.split(os.pathsep):
dir = os.path.expanduser(os.path.expandvars(dir))
if dir not in sys.path:
sys.path.append(dir)
import ZODB # Must import this first to initialize Persistence properly
This diff is collapsed.
"""Empty file to make this directory a Python package."""
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<p xmlns:z="http://xml.zope.org/namespaces/tal">
<span z:define="local x str:hello brave new world">
<span z:content="text local:x">outer variable x, first appearance</span>
<span z:define="local x str:goodbye cruel world">
<span z:content="text local:x">inner variable x</span>
</span>
<span z:content="text local:x">outer variable x, second appearance</span>
</span>
</p>
<?xml version="1.0" ?>
<p xmlns:z="http://xml.zope.org/namespaces/tal">
<span z:define="local x str:hello brave new world">
<span z:content="text local:x">outer variable x, first appearance</span>
<span z:define="local x str:goodbye cruel world">
<span z:content="text local:x">inner variable x</span>
</span>
<span z:content="text local:x">outer variable x, second appearance</span>
</span>
</p>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<html>
<body xmlns:m="http://xml.zope.org/namespaces/metal"
m:use-macro="tests/input/test05.html/body">
dummy body in test6
</body>
</html>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<input name="Delete" i18n:attributes="name">
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<span tal:attributes="class string:foo">Should not get attr in metal</span>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment