From 0d857844b12b033ee8ecdbcfa474781f835bee59 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Sun, 14 Oct 2012 16:26:23 -0500 Subject: [PATCH] Added rudimentary route "mounting" w/ werkzeug routes; fixed auth routes auth routes fixes: - mounted the auth routes at /auth/ - removed crufty old verification email route --- mediagoblin/auth/routing.py | 50 +++++++++++++---------------------- mediagoblin/routing.py | 15 ++++++++++- mediagoblin/submit/routing.py | 2 +- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/mediagoblin/auth/routing.py b/mediagoblin/auth/routing.py index ee4b957a..145761ea 100644 --- a/mediagoblin/auth/routing.py +++ b/mediagoblin/auth/routing.py @@ -14,36 +14,22 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from mediagoblin.routing import add_route -add_route('mediagoblin.auth.logout', - '/auth/logout/', 'mediagoblin.auth.views:logout') - - -add_route('mediagoblin.auth.register', '/register/', - 'mediagoblin.auth.views:register') - -add_route('mediagoblin.auth.login', '/login/', - 'mediagoblin.auth.views:login') - -add_route('mediagoblin.auth.logout', '/logout/', - 'mediagoblin.auth.views:logout') - -add_route('mediagoblin.auth.verify_email', '/verify_email/', - 'mediagoblin.auth.views:verify_email') - -add_route('mediagoblin.auth.resend_verification', '/resend_verification/', - 'mediagoblin.auth.views:resend_activation') - -# XXX: Does this work? -add_route('mediagoblin.auth.resend_verification_success', - '/resend_verification_success/', - # template='mediagoblin/auth/resent_verification_email.html', - 'mediagoblin.views:simple_template_render') - -add_route('mediagoblin.auth.forgot_password', '/forgot_password/', - 'mediagoblin.auth.views:forgot_password') - -add_route('mediagoblin.auth.verify_forgot_password', - '/forgot_password/verify/', - 'mediagoblin.auth.views:verify_forgot_password') +auth_routes = [ + ('mediagoblin.auth.logout', + '/logout/', 'mediagoblin.auth.views:logout'), + ('mediagoblin.auth.register', '/register/', + 'mediagoblin.auth.views:register'), + ('mediagoblin.auth.login', '/login/', + 'mediagoblin.auth.views:login'), + ('mediagoblin.auth.logout', '/logout/', + 'mediagoblin.auth.views:logout'), + ('mediagoblin.auth.verify_email', '/verify_email/', + 'mediagoblin.auth.views:verify_email'), + ('mediagoblin.auth.resend_verification', '/resend_verification/', + 'mediagoblin.auth.views:resend_activation'), + ('mediagoblin.auth.forgot_password', '/forgot_password/', + 'mediagoblin.auth.views:forgot_password'), + ('mediagoblin.auth.verify_forgot_password', + '/forgot_password/verify/', + 'mediagoblin.auth.views:verify_forgot_password')] diff --git a/mediagoblin/routing.py b/mediagoblin/routing.py index 4b9c42ee..8f0f37a5 100644 --- a/mediagoblin/routing.py +++ b/mediagoblin/routing.py @@ -21,15 +21,28 @@ url_map = Map() view_functions = {'index': 'mediagoblin.views:index'} def add_route(endpoint, url, controller): + """ + Add a route to the url mapping + """ view_functions.update({endpoint: controller}) url_map.add(Rule(url, endpoint=endpoint)) +def mount(mountpoint, routes): + """ + Mount a bunch of routes to this mountpoint + """ + for endpoint, url, controller in routes: + url = "%s/%s" % (mountpoint.rstrip('/'), url.lstrip('/')) + add_route(endpoint, url, controller) + add_route('index', '/', 'mediagoblin.views:root_view') import mediagoblin.submit.routing import mediagoblin.user_pages.routing -import mediagoblin.auth.routing import mediagoblin.edit.routing import mediagoblin.webfinger.routing import mediagoblin.listings.routing + +from mediagoblin.auth.routing import auth_routes +mount('/auth', auth_routes) diff --git a/mediagoblin/submit/routing.py b/mediagoblin/submit/routing.py index cbed1895..fbe3c39c 100644 --- a/mediagoblin/submit/routing.py +++ b/mediagoblin/submit/routing.py @@ -18,4 +18,4 @@ from mediagoblin.routing import add_route add_route('mediagoblin.submit.start', '/submit/', 'mediagoblin.submit.views:submit_start') -add_route('collection_home', '/submit/collection', 'mediagoblin.submit.views:add_collection') +add_route('mediagoblin.submit.collection', '/submit/collection', 'mediagoblin.submit.views:add_collection') -- 2.25.1