[Zope3-checkins] CVS: Zope3/src/zope/tales - expressions.py:1.8 interfaces.py:1.4

Philipp von Weitershausen philikon at philikon.de
Wed Mar 3 21:04:14 EST 2004


Update of /cvs-repository/Zope3/src/zope/tales
In directory cvs.zope.org:/tmp/cvs-serv20441/tales

Modified Files:
	expressions.py interfaces.py 
Log Message:
Added ITALESExpression interface; it is implemented by all tales
expression type handlers. It serves mere documentational purposes.


=== Zope3/src/zope/tales/expressions.py 1.7 => 1.8 ===
--- Zope3/src/zope/tales/expressions.py:1.7	Wed Nov  5 14:38:13 2003
+++ Zope3/src/zope/tales/expressions.py	Wed Mar  3 21:04:13 2004
@@ -15,14 +15,15 @@
 
 $Id$
 """
-__metaclass__ = type # All classes are new style when run with Python 2.2+
-
 import re
 from types import StringTypes, TupleType
 
+from zope.interface import implements
 from zope.tales.tales import CompilerError
 from zope.tales.tales import _valid_name, _parse_expr, NAME_RE, Undefined 
-from zope.tales.interfaces import ITALESFunctionNamespace
+from zope.tales.interfaces import ITALESExpression, ITALESFunctionNamespace
+
+__metaclass__ = type
 
 Undefs = (Undefined, AttributeError, KeyError, TypeError, IndexError)
 
@@ -45,6 +46,7 @@
 
 
 class SubPathExpr:
+
     def __init__(self, path, traverser, engine):
         self._traverser = traverser
         self._engine = engine
@@ -141,8 +143,8 @@
 
 
 class PathExpr:
-    """One or more subpath expressions, separated by '|'.
-    """
+    """One or more subpath expressions, separated by '|'."""
+    implements(ITALESExpression)
 
     # _default_type_names contains the expression type names this
     # class is usually registered for.
@@ -215,6 +217,8 @@
 _interp = re.compile(r'\$(%(n)s)|\${(%(n)s(?:/[^}]*)*)}' % {'n': NAME_RE})
 
 class StringExpr:
+    implements(ITALESExpression)
+
     def __init__(self, name, expr, engine):
         self._s = expr
         if '%' in expr:
@@ -256,6 +260,8 @@
 
 
 class NotExpr:
+    implements(ITALESExpression)
+
     def __init__(self, name, expr, engine):
         self._s = expr = expr.lstrip()
         self._c = engine.compile(expr)
@@ -280,6 +286,8 @@
 
 
 class DeferExpr:
+    implements(ITALESExpression)
+
     def __init__(self, name, expr, compiler):
         self._s = expr = expr.lstrip()
         self._c = compiler.compile(expr)
@@ -293,6 +301,7 @@
 
 class SimpleModuleImporter:
     """Minimal module importer with no security."""
+
     def __getitem__(self, module):
         mod = __import__(module)
         path = module.split('.')


=== Zope3/src/zope/tales/interfaces.py 1.3 => 1.4 ===
--- Zope3/src/zope/tales/interfaces.py:1.3	Tue Sep 16 18:11:26 2003
+++ Zope3/src/zope/tales/interfaces.py	Wed Mar  3 21:04:13 2004
@@ -30,6 +30,17 @@
     def setEngine(engine):
         """Sets the engine that is used to evaluate TALES expressions.""" 
 
+class ITALESExpression(Interface):
+    """TALES expression
+
+    These are expression handlers that handle a specific type of
+    expression in TALES, e.g. path or string expression.
+    """
+
+    def __call__(econtext):
+        """Evaluate expression according to the given execution
+        context 'econtext' and return computed value.
+        """
 
 if tal is not None:
     from zope.tal.interfaces import ITALIterator




More information about the Zope3-Checkins mailing list