[Zope-Checkins] CVS: Zope3/lib/python/Zope/TAL - driver.py:1.30
Barry Warsaw
barry@wooz.org
Mon, 17 Jun 2002 20:16:57 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/TAL
In directory cvs.zope.org:/tmp/cvs-serv24097/lib/python/Zope/TAL
Modified Files:
driver.py
Log Message:
Some better debugging tools.
TimeFormatTranslation -> TestTranslations: and teach it about msgid ==
'jobnum'
TimeEngine -> TestEngine: and teach it about the expression
"context/@@object_name".
ENGINES: Include test26.html
=== Zope3/lib/python/Zope/TAL/driver.py 1.29 => 1.30 ===
FILE = "tests/input/test01.xml"
-class TimeFormatTranslation(DummyTranslationService):
+class TestTranslations(DummyTranslationService):
def translate(self, domain, msgid, mapping=None, context=None,
target_language=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
return DummyTranslationService.translate(self, domain, msgid,
mapping, context,
target_language)
-class TimeEngine(DummyEngine):
+class TestEngine(DummyEngine):
def __init__(self, macros=None):
DummyEngine.__init__(self, macros)
- self.translationService = TimeFormatTranslation()
+ self.translationService = TestTranslations()
def evaluatePathOrVar(self, expr):
- expr = expr.strip()
- parts = expr.split('/')
- if parts[0] == 'here' and parts[1] == 'currentTime':
+ if expr == 'here/currentTime':
return {'hours' : 6,
'minutes': 59,
'ampm' : 'PM',
}
+ elif expr == 'context/@@object_name':
+ return '7'
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': TimeEngine,
- 'test24.html': TimeEngine,
+ENGINES = {'test23.html': TestEngine,
+ 'test24.html': TestEngine,
+ 'test26.html': TestEngine,
}
def usage(code, msg=''):