diff --git a/context_processors.py b/context_processors.py index 37c5912..603f78b 100644 --- a/context_processors.py +++ b/context_processors.py @@ -5,20 +5,25 @@ """ This function is a wrapper to render a list of all available List registered to the current request URL """ - #get the URL - try: - web_host = request.META["HTTP_HOST"].split(":")#TODO Django DEV only ! - web_host = web_host[0] - except: - web_host = request.META["HTTP_HOST"] - #querry the Domain object - c = Client('http://localhost:8001/3.0', API_USER, API_PASS) - d = c.get_domain(None,web_host) - #workaround LP:802971 - domainname= d.email_host domain_lists = [] - for list in c.lists: - if list.host_name == domainname: - domain_lists.append(list) + try: + #get the URL + try: + web_host = request.META["HTTP_HOST"].split(":")#TODO Django DEV only ! + web_host = web_host[0] + except: + web_host = request.META["HTTP_HOST"] + #querry the Domain object + c = Client('http://localhost:8001/3.0', API_USER, API_PASS) + d = c.get_domain(None,web_host) + #workaround LP:802971 + domainname= d.email_host + + for list in c.lists: + if list.host_name == domainname: + domain_lists.append(list) + except: + pass #in case there is not http_host (e.g. during testing) + #return a Dict with the key used in templates return {"lists":domain_lists} diff --git a/tests/setup.py b/tests/setup.py index 1314304..d5b1f53 100644 --- a/tests/setup.py +++ b/tests/setup.py @@ -3,7 +3,7 @@ import shutil import tempfile import subprocess -from django.settings import MAILMAN_TEST_BINDIR +from settings import MAILMAN_TEST_BINDIR class Testobject: bindir = None