[llvm-commits] [LNT] r165444 - /lnt/trunk/lnt/server/ui/app.py

Daniel Dunbar daniel at zuster.org
Mon Oct 8 16:02:42 PDT 2012


Author: ddunbar
Date: Mon Oct  8 18:02:42 2012
New Revision: 165444

URL: http://llvm.org/viewvc/llvm-project?rev=165444&view=rev
Log:
lnt.server.ui: Factor out function for creating basic environment.

Modified:
    lnt/trunk/lnt/server/ui/app.py

Modified: lnt/trunk/lnt/server/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/app.py?rev=165444&r1=165443&r2=165444&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/app.py (original)
+++ lnt/trunk/lnt/server/ui/app.py Mon Oct  8 18:02:42 2012
@@ -86,7 +86,7 @@
         app = App(__name__)
 
         # Register additional filters.
-        lnt.server.ui.filters.register(app.jinja_env)
+        create_jinja_environment(app.jinja_env)
 
         # Set up strict undefined mode for templates.
         app.jinja_env.undefined = jinja2.StrictUndefined
@@ -121,7 +121,22 @@
             app=current_app,
             old_config=self.old_config)
 
-        lnt.server.ui.globals.register(self.jinja_env)
-
         # Set the application secret key.
         self.secret_key = self.old_config.secretKey
+
+
+def create_jinja_environment(env=None):
+    """
+    create_jinja_environment([env]) -> jinja2.Environment
+
+    Create (or modify) a new Jinja2 environment suitable for rendering the LNT
+    templates.
+    """
+
+    if env is None:
+        env = jinja2.Environment(loader=jinja2.PackageLoader(
+                'lnt.server.ui', 'templates'))
+    lnt.server.ui.globals.register(env)
+    lnt.server.ui.filters.register(env)
+
+    return env





More information about the llvm-commits mailing list