Added rudimentary route "mounting" w/ werkzeug routes; fixed auth routes
authorChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 14 Oct 2012 21:26:23 +0000 (16:26 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Sun, 14 Oct 2012 21:26:23 +0000 (16:26 -0500)
auth routes fixes:
 - mounted the auth routes at /auth/
 - removed crufty old verification email route

mediagoblin/auth/routing.py
mediagoblin/routing.py
mediagoblin/submit/routing.py

index ee4b957a04ca0ec2d34bd4d87886b99a9384ab75..145761eaee5f1ed16a8ce03b7f11e3f3356babb4 100644 (file)
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-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')]
index 4b9c42ee5baeb81299a593b0d431f1ef082964fe..8f0f37a50d81a3710950273371d73026623dc3ea 100644 (file)
@@ -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)
index cbed18950908f5b286296b7df4612da836e8c367..fbe3c39c3badf9051e82bbddd2a476ebab1d7902 100644 (file)
@@ -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')