Index: trunk/DNSDB/ExportBIND.pm
===================================================================
--- trunk/DNSDB/ExportBIND.pm	(revision 852)
+++ trunk/DNSDB/ExportBIND.pm	(revision 853)
@@ -60,21 +60,4 @@
 
 
-    # fetch a list of views/locations present in the zone.  we need to publish a file for each one.
-    # in the event that no locations are present (~~ $viewlist is empty), /%view collapses to nothing in the zone path
-    my (@loclist) = $self->{dbh}->selectrow_array("SELECT DISTINCT location FROM records WHERE rdns_id = ?", undef, $revid);
-    push @loclist, $defloc unless grep /$defloc/, @loclist;
-    my $zonepath = $self->{bind_export_zone_path};
-    my %zonefiles;  # to be a list of file handles.
-##fixme:  convert logical revzone into .arpa name
-    foreach my $loc (@loclist) {
-      my $zfilepath = $zonepath;
-      $zonepath =~ s/\%view/$loc/;
-      $zonepath =~ s/\%zone/$revzone/;
-      # Just In Case(TM)
-      $zonepath =~ s,[^\w./-],_,g;
-      #open $zonefiles{$loc}, ">", $zfilepath;
-print "open zonefile for '$loc', '$zonepath'\n";
-    }
-
     eval {
 
@@ -90,4 +73,22 @@
           $zonefilehandle = *ZONECACHE;
         }
+
+        # fetch a list of views/locations present in the zone.  we need to publish a file for each one.
+        # in the event that no locations are present (~~ $viewlist is empty), /%view collapses to nothing in the zone path
+        my (@loclist) = $self->{dbh}->selectrow_array("SELECT DISTINCT location FROM records WHERE rdns_id = ?", undef, $revid);
+        push @loclist, $defloc unless grep /$defloc/, @loclist;
+        my $zonepath = $self->{bind_export_zone_path};
+        my %zonefiles;  # to be a list of file handles.
+##fixme:  convert logical revzone into .arpa name
+        foreach my $loc (@loclist) {
+          my $zfilepath = $zonepath;
+          $zfilepath =~ s/\%view/$loc/;
+          $zfilepath =~ s/\%zone/$revzone/;
+          # Just In Case(TM)
+          $zfilepath =~ s,[^\w./-],_,g;
+          #open $zonefiles{$loc}, ">", $zfilepath;
+print "open zonefile for '$loc', '$zfilepath'\n";
+        }
+
 
         # need to fetch this separately since the rest of the records all (should) have real IPs in val
