#NEWLINE# def build_zone_data( view , root_domain , soa , logf = None ) : #NEWLINE# #INDENT# '\n    This function does the heavy lifting of building a zone. It coordinates\n    getting all of the data out of the db into BIND format.\n\n    :param soa: The SOA corresponding to the zone being built.\n    :type soa: SOA\n\n    :param root_domain: The root domain of this zone.\n    :type root_domain: str\n\n    :returns public_file_path: The path to the zone file in the STAGEING dir\n    :type public_file_path: str\n    :returns public_data: The data that should be written to public_file_path\n    :type public_data: str\n\n    :returns view_zone_file: The path to the zone file in the STAGEING dir\n    :type view_zone_file: str\n    :param view_data: The data that should be written to view_zone_file\n    :type view_data: str\n    ' #NEWLINE# ztype = ( 'reverse' if root_domain . is_reverse else 'forward' ) #NEWLINE# if ( soa . has_record_set ( view = view , exclude_ns = True ) and ( not root_domain . nameserver_set . filter ( views = view ) . exists ( ) ) ) : #NEWLINE# #INDENT# msg = "The {0} zone has a records in the {1} view, but there are no nameservers in that view. A zone file for {1} won't be built. Use the search string 'zone=:{0} view=:{1}' to find the troublesome records" . format ( root_domain , view . name ) #NEWLINE# fail_mail ( msg , subject = 'Shitty edge case detected.' ) #NEWLINE# logf ( 'LOG_WARNING' , msg ) #NEWLINE# return '' #NEWLINE# #UNINDENT# domains = soa . domain_set . all ( ) . order_by ( 'name' ) #NEWLINE# domain_mega_filter = Q ( domain = root_domain ) #NEWLINE# for domain in domains : #NEWLINE# #INDENT# domain_mega_filter = ( domain_mega_filter | Q ( domain = domain ) ) #NEWLINE# #UNINDENT# rdomain_mega_filter = Q ( reverse_domain = root_domain ) #NEWLINE# for reverse_domain in domains : #NEWLINE# #INDENT# rdomain_mega_filter = ( rdomain_mega_filter | Q ( reverse_domain = reverse_domain ) ) #NEWLINE# #UNINDENT# soa_data = render_soa_only ( soa = soa , root_domain = root_domain ) #NEWLINE# try : #NEWLINE# #INDENT# if ( ztype == 'forward' ) : #NEWLINE# #INDENT# view_data = render_forward_zone ( view , domain_mega_filter ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# view_data = render_reverse_zone ( view , domain_mega_filter , rdomain_mega_filter ) #NEWLINE# #UNINDENT# #UNINDENT# except View . DoesNotExist : #NEWLINE# #INDENT# view_data = '' #NEWLINE# #UNINDENT# if view_data : #NEWLINE# #INDENT# view_data = ( soa_data + view_data ) #NEWLINE# #UNINDENT# return view_data