[Zope3-checkins] CVS: Zope3/src/zope/tales - expressions.py:1.6 interfaces.py:1.3

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Sep 16 18:11:57 EDT 2003


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

Modified Files:
	expressions.py interfaces.py 
Log Message:
Now TALES namesspaces have access to the context (engine) of the program.
This way they can use 'request' and all other defined variables. All name-
spaces have to implement 'ITALESFunctionNamespace' now. 

Currently the interface only specifies a setEngine() method, which is not
that user friendly. We might want to make a couple convinience methods 
available aas well later.


=== Zope3/src/zope/tales/expressions.py 1.5 => 1.6 ===
--- Zope3/src/zope/tales/expressions.py:1.5	Fri Jun 20 02:41:28 2003
+++ Zope3/src/zope/tales/expressions.py	Tue Sep 16 18:11:26 2003
@@ -22,6 +22,7 @@
 
 from zope.tales.tales import CompilerError
 from zope.tales.tales import _valid_name, _parse_expr, NAME_RE, Undefined 
+from zope.tales.interfaces import ITALESFunctionNamespace
 
 Undefs = (Undefined, AttributeError, KeyError, TypeError, IndexError)
 
@@ -130,6 +131,9 @@
                 ob = self._traverser(ob, val, econtext)
             elif callable(element):
                 ob = element(ob)
+                # XXX: Once we have n-ary adapters, use them.
+                if ITALESFunctionNamespace.isImplementedBy(ob):
+                    ob.setEngine(econtext)
             else:
                 raise "Waagh!"
         return ob


=== Zope3/src/zope/tales/interfaces.py 1.2 => 1.3 ===
--- Zope3/src/zope/tales/interfaces.py:1.2	Wed Jun 11 05:12:39 2003
+++ Zope3/src/zope/tales/interfaces.py	Tue Sep 16 18:11:26 2003
@@ -15,11 +15,21 @@
 
 $Id$
 """
+from zope.interface import Interface
 
 try:
     from zope import tal
 except ImportError:
     tal = None
+
+
+class ITALESFunctionNamespace(Interface):
+    """Function namespaces can be used in TALES path expressions to extract
+    information in non-default ways."""
+
+    def setEngine(engine):
+        """Sets the engine that is used to evaluate TALES expressions.""" 
+
 
 if tal is not None:
     from zope.tal.interfaces import ITALIterator




More information about the Zope3-Checkins mailing list