Commits

Branko Vukelic  committed db7db75

Fixed object modifying context

  • Participants
  • Parent commits 25dff1b

Comments (0)

Files changed (2)

File url_tools/helper.py

 
 
 class UrlHelper(object):
-    _hash = None
-
     def __init__(self, full_path):
         # parse the path
         r = urlparse.urlparse(full_path)
         return self.query_dict
 
     def update_query_data(self, **kwargs):
-        self._hash = None
         for key in kwargs:
             val = kwargs[key]
             if hasattr(val, '__iter__'):
 
     @property
     def hash(self):
-        if self._hash:
-            return self._hash
         md5 = hashlib.md5()
         md5.update(self.get_full_path())
-        self._hash = md5.hexdigest()
-        return self._hash
+        return md5.hexdigest()
 
     @property
     def query(self):
 
     @query.setter
     def query(self, value):
-        self._hash = None
         if type(value) is dict:
             self.query_dict = QueryDict('', mutable=True)
             self.update_query_data(**value)
 
     @query_string.setter
     def query_string(self, value):
-        self._hash = None
         self.query_dict = QueryDict(value, mutable=True)
 
     def __str__(self):

File url_tools/templatetags/urls.py

 
 @register.simple_tag
 def add_params(url, **kwargs):
-    if type(url) in [str, unicode]:
-        url = UrlHelper(url)
+    if type(url) == UrlHelper:
+        url = url.get_full_path()
+    url = UrlHelper(url)
     try:
         url.update_query_data(**kwargs)
         return url.get_full_path()
 
 @register.simple_tag
 def del_params(url, *args):
-    if type(url) in [str, unicode]:
-        url = UrlHelper(url)
+    if type(url) == UrlHelper:
+        url = url.get_full_path()
+    url = UrlHelper(url)
     try:
         url.del_params(*args)
         return url.get_full_path()