summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-12-11 01:23:41 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-12-11 01:23:41 +0000
commit3cad46423f19f1d6ad7d2e1f6f9bd76ff74d21f6 (patch)
treed91356d0248e325f80db94b1201ab351b24d4493
parent2c65324037dd0171dbce455acb664a5ea0a28864 (diff)
downloadmako-3cad46423f19f1d6ad7d2e1f6f9bd76ff74d21f6.tar.gz
caching layer for ns...
-rw-r--r--lib/mako/runtime.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/mako/runtime.py b/lib/mako/runtime.py
index d9fb4b3..bc4f274 100644
--- a/lib/mako/runtime.py
+++ b/lib/mako/runtime.py
@@ -99,8 +99,13 @@ class Namespace(object):
def get_namespace(self, filename):
"""return a namespace corresponding to the given template filename."""
- # TODO: add a caching layer here
- return Namespace(filename, self.context, templateuri=filename, calling_uri=self._templateuri)
+ key = (self, filename)
+ if self.context.namespaces.has_key(key):
+ return context.namespaces[key]
+ else:
+ ns = Namespace(filename, self.context, templateuri=filename, calling_uri=self._templateuri)
+ self.context.namespaces[key] = ns
+ return ns
def populate(self, d, l):
for ident in l: