[copr] master: Clean main __init__.py by moving the before_request handler and errorhandler to views.misc, where they belong (25a857e)

bkabrda at fedoraproject.org bkabrda at fedoraproject.org
Fri Jan 25 12:27:50 UTC 2013


Repository : http://git.fedorahosted.org/cgit/copr.git

On branch  : master

>---------------------------------------------------------------

commit 25a857eb7522e0a265ca8e5ad863488bbdf1cb20
Author: Bohuslav Kabrda <bkabrda at redhat.com>
Date:   Fri Jan 25 11:56:56 2013 +0100

    Clean main __init__.py by moving the before_request handler and errorhandler to views.misc, where they belong


>---------------------------------------------------------------

 coprs_frontend/coprs/__init__.py                   |   11 -----------
 .../coprs/views/coprs_ns/coprs_builds.py           |    4 ++--
 .../coprs/views/coprs_ns/coprs_general.py          |    4 ++--
 coprs_frontend/coprs/views/misc.py                 |   11 +++++++++++
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/coprs_frontend/coprs/__init__.py b/coprs_frontend/coprs/__init__.py
index a96ace9..d5d732a 100644
--- a/coprs_frontend/coprs/__init__.py
+++ b/coprs_frontend/coprs/__init__.py
@@ -18,17 +18,6 @@ else:
 oid = OpenID(app, app.config['OPENID_STORE'])
 db = SQLAlchemy(app)
 
- at app.before_request
-def lookup_current_user():
-    flask.g.user = None
-    if 'openid' in flask.session:
-        flask.g.user = models.User.query.filter(models.User.openid_name == flask.session['openid']).first()
-
-
- at app.errorhandler(404)
-def page_not_found(message):
-    return flask.render_template('404.html', message = message), 404
-
 import coprs.filters
 import coprs.log
 import coprs.models
diff --git a/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py b/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py
index 9180d95..eae3c1d 100644
--- a/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py
+++ b/coprs_frontend/coprs/views/coprs_ns/coprs_builds.py
@@ -2,7 +2,7 @@ import time
 
 import flask
 
-from coprs import db, page_not_found
+from coprs import db
 from coprs import exceptions
 from coprs import forms
 from coprs import helpers
@@ -11,7 +11,7 @@ from coprs import models
 from coprs.logic import builds_logic
 from coprs.logic import coprs_logic
 
-from coprs.views.misc import login_required
+from coprs.views.misc import login_required, page_not_found
 from coprs.views.coprs_ns import coprs_ns
 from coprs.views.coprs_ns import coprs_general
 
diff --git a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
index a1acad6..662246e 100644
--- a/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
+++ b/coprs_frontend/coprs/views/coprs_ns/coprs_general.py
@@ -2,13 +2,13 @@ import time
 
 import flask
 
-from coprs import db, page_not_found
+from coprs import db
 from coprs import exceptions
 from coprs import forms
 from coprs import helpers
 from coprs import models
 
-from coprs.views.misc import login_required
+from coprs.views.misc import login_required, page_not_found
 
 from coprs.views.coprs_ns import coprs_ns
 
diff --git a/coprs_frontend/coprs/views/misc.py b/coprs_frontend/coprs/views/misc.py
index 4dadce9..e681b48 100644
--- a/coprs_frontend/coprs/views/misc.py
+++ b/coprs_frontend/coprs/views/misc.py
@@ -13,6 +13,17 @@ from coprs import db
 from coprs import models
 from coprs import oid
 
+ at app.before_request
+def lookup_current_user():
+    flask.g.user = None
+    if 'openid' in flask.session:
+        flask.g.user = models.User.query.filter(models.User.openid_name==flask.session['openid']).first()
+
+ at app.errorhandler(404)
+def page_not_found(message):
+    return flask.render_template('404.html', message=message), 404
+
+
 misc = flask.Blueprint('misc', __name__)
 
 def generate_api_token(size=30):



More information about the copr-devel mailing list