Dolda2000 GitWeb
/
wrw.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3162cb8
)
Made the wmako library an environment variable.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Thu, 5 Jul 2012 03:19:06 +0000
(
05:19
+0200)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Thu, 5 Jul 2012 03:19:06 +0000
(
05:19
+0200)
wrw/wmako.py
patch
|
blob
|
blame
|
history
diff --git
a/wrw/wmako.py
b/wrw/wmako.py
index
9945345
..
491d8b3
100644
(file)
--- a/
wrw/wmako.py
+++ b/
wrw/wmako.py
@@
-1,6
+1,6
@@
import os, threading
from mako import template, lookup, filters
import os, threading
from mako import template, lookup, filters
-import util, form, session
+import util, form, session
, env
# It seems Mako isn't thread-safe.
makolock = threading.Lock()
# It seems Mako isn't thread-safe.
makolock = threading.Lock()
@@
-25,13
+25,19
@@
defargs = {"output_encoding": "utf-8",
"default_filters": ["decode.utf8"],
"module_directory": cachedir,
}
"default_filters": ["decode.utf8"],
"module_directory": cachedir,
}
-lib = liblookup(directories = libdirs, **defargs)
+
+def makelib(init=liblookup, directories=[], **kwargs):
+ ad = dict(defargs)
+ ad.update(kwargs)
+ return init(directories = libdirs + directories, **ad)
+
+lib = env.var(makelib())
if not os.path.exists(cachedir):
os.mkdir(cachedir)
def handle(req, filename, **kw):
with makolock:
if not os.path.exists(cachedir):
os.mkdir(cachedir)
def handle(req, filename, **kw):
with makolock:
- tt = template.Template(filename = filename, lookup = lib, **defargs)
+ tt = template.Template(filename = filename, lookup = lib
.val
, **defargs)
req.ohead["Content-Type"] = "text/html; charset=utf-8"
return [tt.render(request = req, **kw)]
req.ohead["Content-Type"] = "text/html; charset=utf-8"
return [tt.render(request = req, **kw)]