]> git.parisson.com Git - teleforma.git/commitdiff
except for urrlib
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 23 Nov 2023 08:12:21 +0000 (09:12 +0100)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Thu, 23 Nov 2023 08:12:21 +0000 (09:12 +0100)
teleforma/templatetags/teleforma_tags.py

index ff1e2b4b4046a3a88bc3ee73dfa7ced85f911f7d..ee6a1cee92e2d504ee5965264de915f5c58acb08 100644 (file)
@@ -280,11 +280,14 @@ def get_video_id(media):
 
 @register.filter
 def get_host(url, host):
-    u = urlparse(url)
-    if host == '127.0.0.1' or host == 'localhost':
-        nu = u.scheme + '://' + host + ':' + str(u.port) + u.path
-        return nu
-    else:
+    try:
+        #TODO adapt to urllib py3
+        # https://stackoverflow.com/questions/12772190/urllib-module-object-is-not-callable
+        u = urlparse(url)
+        if host == '127.0.0.1' or host == 'localhost':
+            nu = u.scheme + '://' + host + ':' + str(u.port) + u.path
+            return nu
+    except:
         return url