[Zope3-checkins] CVS: Zope3/src/zope/tales/tests -
test_expressions.py:1.4
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Sep 16 18:11:27 EDT 2003
Update of /cvs-repository/Zope3/src/zope/tales/tests
In directory cvs.zope.org:/tmp/cvs-serv13611/src/zope/tales/tests
Modified Files:
test_expressions.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/tests/test_expressions.py 1.3 => 1.4 ===
--- Zope3/src/zope/tales/tests/test_expressions.py:1.3 Thu May 1 15:35:50 2003
+++ Zope3/src/zope/tales/tests/test_expressions.py Tue Sep 16 18:11:27 2003
@@ -11,9 +11,15 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
+"""Default TALES expression implementations tests.
+
+$Id$
+"""
import unittest
from zope.tales.engine import Engine
+from zope.tales.interfaces import ITALESFunctionNamespace
+from zope.interface import implements
class Data:
@@ -127,10 +133,17 @@
# a test namespace
class TestNameSpace:
+ implements(ITALESFunctionNamespace)
def __init__(self, context):
self.context = context
+ def setEngine(self, engine):
+ self._engine = engine
+
+ def engine(self):
+ return self._engine
+
def upper(self):
return str(self.context).upper()
@@ -143,7 +156,11 @@
self.engine.registerFunctionNamespace('namespace',self.TestNameSpace)
## framework-ish tests
-
+
+ def testSetEngine(self):
+ expr = self.engine.compile('adapterTest/namespace:engine')
+ self.assertEqual(expr(self.context), self.engine)
+
def testGetFunctionNamespace(self):
self.assertEqual(
self.engine.getFunctionNamespace('namespace'),
More information about the Zope3-Checkins
mailing list