Commits

Branko Vukelic committed 289973e

Added get_full_quoted_path method

This method returns the full path of the UrlHelper as quoted string useful for
using in query parameters.

  • Participants
  • Parent commits e6c989e

Comments (0)

Files changed (2)

File tests/test_url_helper.py

         u.query_string = 'foo=1&bar=2'
         self.assertEqual(u.query['foo'], '1')
         self.assertEqual(u.query['bar'], '2')
+
+    def test_get_full_quoted_path(self):
+        u = UrlHelper('/foo/bar?foo=1&bar=2#foo')
+        self.assertEqual(u.get_full_quoted_path(),
+                         '/foo/bar%3Ffoo%3D1%26bar%3D2%23foo')

File url_tools/helper.py

 from __future__ import absolute_import, unicode_literals
 
+import urllib
 import urlparse
 
 from django.http.request import QueryDict
             fragment
         )
 
+    def get_full_quoted_path(self, **kwargs):
+        return urllib.quote_plus(self.get_full_path(**kwargs), safe='/')
+
     @property
     def query(self):
         return self.get_query_data()