1
2
3
4
5
6
7
8
9
10
11
12
13
14 from Products.PageTemplates.Expressions import getEngine
15 from DateTime import DateTime
16
17 _compiled = {}
18
21
22
24 """Perform a TALES eval on the express using context.
25 """
26 compiled = talesCompile(express)
27 contextDict = { 'here':context,
28 'nothing':None,
29 'now': DateTime(),
30 }
31 if isinstance(extra, dict):
32 contextDict.update(extra)
33 res = compiled(getEngine().getContext(contextDict))
34 if isinstance(res, Exception):
35 raise res
36 return res
37
39 compiled = _compiled.get(express, None)
40 if not compiled:
41 _compiled[express] = compiled = getEngine().compile(express)
42 return compiled
43