From 87d0b08b502d82960d7b149b78713f29a2263e24 Mon Sep 17 00:00:00 2001 From: Jeffrey Forman Date: Sun, 28 Oct 2012 08:45:08 -0400 Subject: [PATCH] clean up listing server zones, remove error_context code --- binder/bcommon/models.py | 2 +- binder/bcommon/views.py | 18 ++++++++---------- binder/templates/base.htm | 5 ----- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/binder/bcommon/models.py b/binder/bcommon/models.py index 4c0f781..800f789 100644 --- a/binder/bcommon/models.py +++ b/binder/bcommon/models.py @@ -24,7 +24,7 @@ class BindServer(models.Model): try: http_request = urllib2.urlopen(myreq) except urllib2.URLError, err_reason: # Error retrieving zone list. - return { 'errors' : err_reason, 'error_context' : "Trying to retrieve zone list from %s" % self.hostname } + return { 'errors' : "Trying to retrieve zone list from %s: %s" % (self.hostname, err_reason) } return_array = [] xmloutput = http_request.read() diff --git a/binder/bcommon/views.py b/binder/bcommon/views.py index 1166af1..0347a1c 100644 --- a/binder/bcommon/views.py +++ b/binder/bcommon/views.py @@ -25,23 +25,21 @@ def view_server_list(request): def view_server_zones(request, dns_server): """ Display the list of DNS zones a particular DNS host provides. """ + errors = "" + zone_array = {} try: this_server = BindServer.objects.get(hostname=dns_server) zone_array = this_server.list_zones() except BindServer.DoesNotExist, err: - return render_to_response('bcommon/list_server_zones.htm', - { 'errors' : "The server %s does not exist in this Binder instance." % dns_server }, - context_instance=RequestContext(request)) + errors = err - if 'errors' in zone_array: - return render_to_response('bcommon/list_server_zones.htm', - { 'errors' : zone_array['errors'], - 'error_context' : zone_array['error_context'] }) + if "errors" in zone_array: + errors = zone_array["errors"] return render_to_response('bcommon/list_server_zones.htm', - { 'zone_array' : zone_array, - 'dns_server' : dns_server }, - context_instance=RequestContext(request)) + { "errors" : errors, + "dns_server" : dns_server, + "zone_array" : zone_array}) def view_zone_records(request, dns_server, zone_name): """ Display the list of records for a a particular zone.""" diff --git a/binder/templates/base.htm b/binder/templates/base.htm index 58ad465..91f9c1c 100644 --- a/binder/templates/base.htm +++ b/binder/templates/base.htm @@ -34,18 +34,13 @@ {% block errors %} - {% if errors %}
Errors were encountered:
{{ errors }} - {% if error_context %} - {{ error_context }} - {% endif %}
{% endif %} - {% endblock errors %} {% block body %}