aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tools
diff options
context:
space:
mode:
authorJessica Tallon <jessica@megworld.co.uk>2014-11-21 13:18:25 +0000
committerJessica Tallon <jessica@megworld.co.uk>2014-11-21 13:30:31 +0000
commit9c602458d830c1ebcd0ede7c14f7ddef79e2a73f (patch)
tree0590894f15068afe176fe9e9ddb6f028c131a089 /mediagoblin/tools
parentf44bd7dc873d6122d32f4d8619f82429096750cf (diff)
downloadmediagoblin-9c602458d830c1ebcd0ede7c14f7ddef79e2a73f.tar.lz
mediagoblin-9c602458d830c1ebcd0ede7c14f7ddef79e2a73f.tar.xz
mediagoblin-9c602458d830c1ebcd0ede7c14f7ddef79e2a73f.zip
Fix #1025 - Make API IDs IRIs
Diffstat (limited to 'mediagoblin/tools')
-rw-r--r--mediagoblin/tools/routing.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/mediagoblin/tools/routing.py b/mediagoblin/tools/routing.py
index a15795fe..2ff003b7 100644
--- a/mediagoblin/tools/routing.py
+++ b/mediagoblin/tools/routing.py
@@ -15,6 +15,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
+import urlparse
import six
from werkzeug.routing import Map, Rule
@@ -65,3 +66,17 @@ def mount(mountpoint, routes):
for endpoint, url, controller in routes:
url = "%s/%s" % (mountpoint.rstrip('/'), url.lstrip('/'))
add_route(endpoint, url, controller)
+
+def extract_url_arguments(url, urlmap):
+ """
+ This extracts the URL arguments from a given URL
+ """
+ parsed_url = urlparse.urlparse(url)
+ map_adapter = urlmap.bind(
+ server_name=parsed_url.netloc,
+ script_name=parsed_url.path,
+ url_scheme=parsed_url.scheme,
+ path_info=parsed_url.path
+ )
+
+ return map_adapter.match()[1]