[llvm-commits] [zorg] r125872 - in /zorg/trunk/llvmlab/llvmlab/ui: app.py frontend/ frontend/__init__.py frontend/views.py views.py
Daniel Dunbar
daniel at zuster.org
Fri Feb 18 08:41:15 PST 2011
Author: ddunbar
Date: Fri Feb 18 10:41:15 2011
New Revision: 125872
URL: http://llvm.org/viewvc/llvm-project?rev=125872&view=rev
Log:
llvmlab: Sink views into a separate module.
Added:
zorg/trunk/llvmlab/llvmlab/ui/frontend/
zorg/trunk/llvmlab/llvmlab/ui/frontend/__init__.py
zorg/trunk/llvmlab/llvmlab/ui/frontend/views.py
- copied, changed from r125871, zorg/trunk/llvmlab/llvmlab/ui/views.py
Removed:
zorg/trunk/llvmlab/llvmlab/ui/views.py
Modified:
zorg/trunk/llvmlab/llvmlab/ui/app.py
Modified: zorg/trunk/llvmlab/llvmlab/ui/app.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/ui/app.py?rev=125872&r1=125871&r2=125872&view=diff
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/ui/app.py (original)
+++ zorg/trunk/llvmlab/llvmlab/ui/app.py Fri Feb 18 10:41:15 2011
@@ -5,7 +5,7 @@
import llvmlab.data
import llvmlab.user
-import llvmlab.ui.views
+from llvmlab.ui.frontend.views import frontend as frontend_views
class App(flask.Flask):
@staticmethod
@@ -20,7 +20,7 @@
app.load_data(data)
# Load the application routes.
- app.register_module(llvmlab.ui.views.ui)
+ app.register_module(frontend_views)
return app
Added: zorg/trunk/llvmlab/llvmlab/ui/frontend/__init__.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/ui/frontend/__init__.py?rev=125872&view=auto
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/ui/frontend/__init__.py (added)
+++ zorg/trunk/llvmlab/llvmlab/ui/frontend/__init__.py Fri Feb 18 10:41:15 2011
@@ -0,0 +1 @@
+__all__ = []
Copied: zorg/trunk/llvmlab/llvmlab/ui/frontend/views.py (from r125871, zorg/trunk/llvmlab/llvmlab/ui/views.py)
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/ui/frontend/views.py?p2=zorg/trunk/llvmlab/llvmlab/ui/frontend/views.py&p1=zorg/trunk/llvmlab/llvmlab/ui/views.py&r1=125871&r2=125872&rev=125872&view=diff
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/ui/views.py (original)
+++ zorg/trunk/llvmlab/llvmlab/ui/frontend/views.py Fri Feb 18 10:41:15 2011
@@ -7,21 +7,21 @@
from flask import url_for
from flask import current_app
from flask import Module
-ui = Module(__name__)
+frontend = Module(__name__)
- at ui.route('/')
+ at frontend.route('/')
def index():
return render_template("index.html")
- at ui.route('/favicon.ico')
+ at frontend.route('/favicon.ico')
def favicon_ico():
return redirect(url_for('.static', filename='favicon.ico'))
- at ui.route('/users')
+ at frontend.route('/users')
def users():
return render_template("users.html")
- at ui.route('/user/<username>')
+ at frontend.route('/user/<username>')
def user(username):
user = current_app.config.data.users.get(username)
if user is None:
@@ -29,7 +29,7 @@
return render_template("user.html", user=user)
- at ui.route('/login', methods=['GET', 'POST'])
+ at frontend.route('/login', methods=['GET', 'POST'])
def login():
# If this isn't a post request, return the login template.
if request.method != 'POST':
@@ -47,7 +47,7 @@
flask.flash('You were logged in as "%s"!' % username)
return redirect(url_for("index"))
- at ui.route('/logout')
+ at frontend.route('/logout')
def logout():
session.pop('logged_in', None)
session.pop('active_user', None)
Removed: zorg/trunk/llvmlab/llvmlab/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/ui/views.py?rev=125871&view=auto
==============================================================================
--- zorg/trunk/llvmlab/llvmlab/ui/views.py (original)
+++ zorg/trunk/llvmlab/llvmlab/ui/views.py (removed)
@@ -1,55 +0,0 @@
-import flask
-from flask import abort
-from flask import redirect
-from flask import render_template
-from flask import request
-from flask import session
-from flask import url_for
-from flask import current_app
-from flask import Module
-ui = Module(__name__)
-
- at ui.route('/')
-def index():
- return render_template("index.html")
-
- at ui.route('/favicon.ico')
-def favicon_ico():
- return redirect(url_for('.static', filename='favicon.ico'))
-
- at ui.route('/users')
-def users():
- return render_template("users.html")
-
- at ui.route('/user/<username>')
-def user(username):
- user = current_app.config.data.users.get(username)
- if user is None:
- abort(404)
-
- return render_template("user.html", user=user)
-
- at ui.route('/login', methods=['GET', 'POST'])
-def login():
- # If this isn't a post request, return the login template.
- if request.method != 'POST':
- return render_template("login.html", error=None)
-
- # Authenticate the user.
- username = request.form['username']
- if not current_app.authenticate_login(username, request.form['password']):
- return render_template("login.html",
- error="Invalid login")
-
- # Log the user in.
- session['logged_in'] = True
- session['active_user'] = username
- flask.flash('You were logged in as "%s"!' % username)
- return redirect(url_for("index"))
-
- at ui.route('/logout')
-def logout():
- session.pop('logged_in', None)
- session.pop('active_user', None)
- flask.flash('You were logged out!')
- return redirect(url_for("index"))
More information about the llvm-commits
mailing list