pngtile.application: url(): helper to construct urls
authorTero Marttila <terom@qmsk.net>
Fri, 03 Oct 2014 21:07:59 +0300
changeset 152 7bd8d6062c9e
parent 151 dfd8022d000e
child 153 55f3d3bc95d3
pngtile.application: url(): helper to construct urls
pngtile/application.py
--- a/pngtile/application.py	Mon Sep 15 01:48:29 2014 +0300
+++ b/pngtile/application.py	Fri Oct 03 21:07:59 2014 +0300
@@ -1,10 +1,19 @@
 from werkzeug import Request, Response, exceptions
 from werkzeug.utils import html
+import werkzeug.urls
 
 import pypngtile
 
 import os.path
 
+def url (server, *path, **args):
+    """
+        >>> url('http://foo/', 'bar, 'quux.png', x=5, y=2)
+        'http://foo/bar/quux.png?x=5&y=2'
+    """
+
+    return werkzeug.urls.Href(server)(*path, **args)
+
 class BaseApplication (object):
     IMAGE_TYPES = (
         'png',