+url_map = Map()
+
+view_functions = {}
+
+def add_route(endpoint, url, controller):
+ """
+ Add a route to the url mapping
+ """
+ # XXX: We cannot use this, since running tests means that the plugin
+ # routes will be populated over and over over the same session.
+ #
+ # assert endpoint not in view_functions.keys(), 'Trying to overwrite a rule'
+
+ 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')
+
+from mediagoblin.admin.routing import admin_routes