[Zope3-checkins] CVS: Zope3/src/zope/tal - dummyengine.py:1.10 interfaces.py:1.7 taldefs.py:1.5 talgettext.py:1.13

Jim Fulton jim@zope.com
Tue, 20 May 2003 16:29:07 -0400


Update of /cvs-repository/Zope3/src/zope/tal
In directory cvs.zope.org:/tmp/cvs-serv30994/src/zope/tal

Modified Files:
	dummyengine.py interfaces.py taldefs.py talgettext.py 
Log Message:
Renamed a bunch of interfaces to reflect the TAL expression, rather
than TALES.


=== Zope3/src/zope/tal/dummyengine.py 1.9 => 1.10 ===
--- Zope3/src/zope/tal/dummyengine.py:1.9	Thu May  1 15:35:49 2003
+++ Zope3/src/zope/tal/dummyengine.py	Tue May 20 16:29:06 2003
@@ -11,14 +11,14 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""
-Dummy TALES engine so that I can test out the TAL implementation.
+"""Dummy TAL expression engine so that I can test out the TAL implementation.
 """
 
 import re
 
-from zope.tal.taldefs import NAME_RE, TALESError, ErrorInfo
-from zope.tal.interfaces import ITALESCompiler, ITALESEngine
+from zope.interface import implements
+from zope.tal.taldefs import NAME_RE, TALExpressionError, ErrorInfo
+from zope.tal.interfaces import ITALExpressionCompiler, ITALExpressionEngine
 from zope.i18n.interfaces import ITranslationService
 
 Default = object()
@@ -33,7 +33,7 @@
     position = None
     source_file = None
 
-    __implements__ = ITALESCompiler, ITALESEngine
+    implements(ITALExpressionCompiler, ITALExpressionEngine)
 
     def __init__(self, macros=None):
         if macros is None:
@@ -99,7 +99,7 @@
             try:
                 return eval(expr, self.globals, self.locals)
             except:
-                raise TALESError("evaluation error in %s" % `expr`)
+                raise TALExpressionError("evaluation error in %s" % `expr`)
         if type == "position":
             # Insert the current source file name, line number,
             # and column offset.
@@ -108,7 +108,7 @@
             else:
                 lineno, offset = None, None
             return '%s (%s,%s)' % (self.source_file, lineno, offset)
-        raise TALESError("unrecognized expression: " + `expression`)
+        raise TALExpressionError("unrecognized expression: " + `expression`)
 
     def evaluatePathOrVar(self, expr):
         expr = expr.strip()
@@ -117,7 +117,7 @@
         elif self.globals.has_key(expr):
             return self.globals[expr]
         else:
-            raise TALESError("unknown variable: %s" % `expr`)
+            raise TALExpressionError("unknown variable: %s" % `expr`)
 
     def evaluateValue(self, expr):
         return self.evaluate(expr)
@@ -153,8 +153,8 @@
             program, macros = driver.compilefile(file)
             macro = macros.get(localName)
             if not macro:
-                raise TALESError("macro %s not found in file %s" %
-                                 (localName, file))
+                raise TALExpressionError("macro %s not found in file %s" %
+                                         (localName, file))
         return macro
 
     def findMacroDocument(self, macroName):
@@ -167,7 +167,7 @@
 
     def findMacroFile(self, macroName):
         if not macroName:
-            raise TALESError("empty macro name")
+            raise TALExpressionError("empty macro name")
         i = macroName.rfind('/')
         if i < 0:
             # No slash -- must be a locally defined macro


=== Zope3/src/zope/tal/interfaces.py 1.6 => 1.7 ===
--- Zope3/src/zope/tal/interfaces.py:1.6	Fri Apr 25 15:28:42 2003
+++ Zope3/src/zope/tal/interfaces.py	Tue May 20 16:29:06 2003
@@ -11,16 +11,16 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-"""Interface that a TALES engine provides to the METAL/TAL implementation."""
+"""Interface that a TAL expression implementation provides to the METAL/TAL implementation."""
 
 from zope.interface import Attribute, Interface
 
 
-class ITALESCompiler(Interface):
-    """Compile-time interface provided by a TALES implementation.
+class ITALExpressionCompiler(Interface):
+    """Compile-time interface provided by a TAL expression implementation.
 
     The TAL compiler needs an instance of this interface to support
-    compilation of TALES expressions embedded in documents containing
+    compilation of TAL expressions embedded in documents containing
     TAL and METAL constructs.
     """
 
@@ -34,22 +34,22 @@
         '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
+        methods of the ITALExpressionEngine interface.  No compatibility is
         required for the values of the compiled expression between
-        different ITALESEngine implementations.
+        different ITALExpressionEngine implementations.
         """
 
 
-class ITALESEngine(Interface):
-    """Render-time interface provided by a TALES implementation.
+class ITALExpressionEngine(Interface):
+    """Render-time interface provided by a TAL expression implementation.
 
-    The TAL interpreter uses this interface to TALES to support
+    The TAL interpreter uses this interface to TAL expression to support
     evaluation of the compiled expressions returned by
-    ITALESCompiler.compile().
+    ITALExpressionCompiler.compile().
     """
 
     def getDefault():
-        """Return the value of the 'default' TALES expression.
+        """Return the value of the 'default' TAL expression.
 
         Checking a value for a match with 'default' should be done
         using the 'is' operator in Python.
@@ -117,7 +117,7 @@
         """
 
     def createErrorInfo(exception, (lineno, offset)):
-        """Returns an ITALESErrorInfo object.
+        """Returns an ITALExpressionErrorInfo object.
 
         The returned object is used to provide information about the
         error condition for the on-error handler.
@@ -136,7 +136,10 @@
         """
 
     def setRepeat(name, compiled_expression):
-        """
+        """Start a repetition, returning an ITALIterator.
+
+        The engine is expected to add the a value (typically the
+        returned iterator) for the name to the variable namespace.
         """
 
     def translate(msgid, domain=None, mapping=None, default=None):
@@ -144,8 +147,22 @@
         See ITranslationService.translate()
         """
 
+class ITALIterator(Interface):
+    """A TAL iterator
+
+    Not to be confused with a Python iterator.
+    """
+
+    def next():
+        """Advance to the next value in the iteration, if possible
+
+        Return a true value if it was possible to advance and return
+        a false value otherwise.
+
+        """
 
-class ITALESErrorInfo(Interface):
+        
+class ITALExpressionErrorInfo(Interface):
 
     type = Attribute("type",
                      "The exception class.")


=== Zope3/src/zope/tal/taldefs.py 1.4 => 1.5 ===
--- Zope3/src/zope/tal/taldefs.py:1.4	Fri Apr  4 10:49:07 2003
+++ Zope3/src/zope/tal/taldefs.py	Tue May 20 16:29:06 2003
@@ -15,7 +15,7 @@
 Common definitions used by TAL and METAL compilation an transformation.
 """
 
-from zope.tal.interfaces import ITALESErrorInfo
+from zope.tal.interfaces import ITALExpressionErrorInfo
 
 TAL_VERSION = "1.4"
 
@@ -84,7 +84,7 @@
 class METALError(TALError):
     pass
 
-class TALESError(TALError):
+class TALExpressionError(TALError):
     pass
 
 class I18NError(TALError):
@@ -93,7 +93,7 @@
 
 class ErrorInfo:
 
-    __implements__ = ITALESErrorInfo
+    __implements__ = ITALExpressionErrorInfo
 
     def __init__(self, err, position=(None, None)):
         if isinstance(err, Exception):


=== Zope3/src/zope/tal/talgettext.py 1.12 => 1.13 ===
--- Zope3/src/zope/tal/talgettext.py:1.12	Thu May  1 15:35:49 2003
+++ Zope3/src/zope/tal/talgettext.py	Tue May 20 16:29:06 2003
@@ -37,8 +37,8 @@
 from zope.tal.htmltalparser import HTMLTALParser
 from zope.tal.talinterpreter import TALInterpreter
 from zope.tal.dummyengine import DummyEngine
-from zope.tal.interfaces import ITALESEngine
-from zope.tal.taldefs import TALESError
+from zope.tal.interfaces import ITALExpressionEngine
+from zope.tal.taldefs import TALExpressionError
 
 __version__ = '$Revision$'
 
@@ -87,7 +87,7 @@
 
 
 class POEngine(DummyEngine):
-    __implements__ = ITALESEngine
+    __implements__ = ITALExpressionEngine
 
     def __init__(self, macros=None):
         self.catalog = {}
@@ -106,7 +106,7 @@
         return True # dummy
 
     def translate(self, msgid, domain=None, mapping=None, default=None,
-                  # XXX position is not part of the ITALESEngine interface
+                  # XXX position is not part of the ITALExpressionEngine interface
                   position=None):
         # assume domain and mapping are ignored; if they are not,
         # unit test must be updated.
@@ -201,7 +201,7 @@
     def evaluate(self, expression):
         try:
             return POEngine.evaluate(self, expression)
-        except TALESError:
+        except TALExpressionError:
             pass
 
     def evaluatePathOrVar(self, expr):