[llvm-commits] [zorg] r147085 - in /zorg/trunk/lnt/lnt/server/ui: app.py globals.py
Daniel Dunbar
daniel at zuster.org
Wed Dec 21 12:00:39 PST 2011
Author: ddunbar
Date: Wed Dec 21 14:00:38 2011
New Revision: 147085
URL: http://llvm.org/viewvc/llvm-project?rev=147085&view=rev
Log:
[lnt/v0.4]: Factor Jinja global extensions out into a separate module.
Added:
zorg/trunk/lnt/lnt/server/ui/globals.py
Modified:
zorg/trunk/lnt/lnt/server/ui/app.py
Modified: zorg/trunk/lnt/lnt/server/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/app.py?rev=147085&r1=147084&r2=147085&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/app.py (original)
+++ zorg/trunk/lnt/lnt/server/ui/app.py Wed Dec 21 14:00:38 2011
@@ -11,6 +11,7 @@
import lnt
import lnt.server.config
import lnt.server.ui.filters
+import lnt.server.ui.globals
import lnt.server.ui.views
import lnt.server.db.v4db
@@ -69,20 +70,6 @@
def get_db_summary(self):
return current_app.get_db_summary(g.db_name, self.get_db())
-def db_url_for(*args, **kwargs):
- """
- Like url_for, but handles automatically providing the db_name argument.
- """
- return url_for(*args, db_name=g.db_name, **kwargs)
-
-def v4_url_for(*args, **kwargs):
- """
- Like url_for, but handles automatically providing the db_name and
- testsuite_name arguments.
- """
- return url_for(*args, db_name=g.db_name, testsuite_name=g.testsuite_name,
- **kwargs)
-
class App(flask.Flask):
@staticmethod
def create_standalone(config_path):
@@ -124,11 +111,11 @@
self.jinja_env.globals.update(
app=current_app,
- db_url_for=db_url_for,
- v4_url_for=v4_url_for,
perfdb=perfdb,
old_config=self.old_config)
+ lnt.server.ui.globals.register(self)
+
def get_db_summary(self, db_name, db):
# FIXME/v3removal: Eliminate this, V4DB style has no need for summary
# abstraction.
Added: zorg/trunk/lnt/lnt/server/ui/globals.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/globals.py?rev=147085&view=auto
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/globals.py (added)
+++ zorg/trunk/lnt/lnt/server/ui/globals.py Wed Dec 21 14:00:38 2011
@@ -0,0 +1,24 @@
+"""
+Module for defining additional Jinja global functions.
+"""
+
+import flask
+
+def db_url_for(*args, **kwargs):
+ """
+ Like url_for, but handles automatically providing the db_name argument.
+ """
+ return flask.url_for(*args, db_name=flask.g.db_name, **kwargs)
+
+def v4_url_for(*args, **kwargs):
+ """
+ Like url_for, but handles automatically providing the db_name and
+ testsuite_name arguments.
+ """
+ return flask.url_for(*args, db_name=flask.g.db_name,
+ testsuite_name=flask.g.testsuite_name, **kwargs)
+
+def register(app):
+ app.jinja_env.globals.update(
+ db_url_for=db_url_for,
+ v4_url_for=v4_url_for)
More information about the llvm-commits
mailing list