#NEWLINE# def smart_fqdn_exists( fqdn , * args , **kwargs ) : #NEWLINE# #INDENT# "\n    Searching for a fqdn by actually looking at a fqdn is very inefficient.\n    Instead we should:\n        1) Look for a domain with the name of fqdn.\n        2) Look for a label = fqdn.split('.')[0]\n            and domain = fqdn.split('.')[1:]\n    " #NEWLINE# try : #NEWLINE# #INDENT# search_domain = mozdns . domain . models . Domain . objects . get ( name = fqdn ) #NEWLINE# label = '' #NEWLINE# #UNINDENT# except ObjectDoesNotExist : #NEWLINE# #INDENT# search_domain = None #NEWLINE# #UNINDENT# if search_domain : #NEWLINE# #INDENT# for ( type_ , qset ) in _build_label_domain_queries ( label , search_domain , ** kwargs ) : #NEWLINE# #INDENT# if qset . exists ( ) : #NEWLINE# #INDENT# return qset #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# search_domain = None #NEWLINE# if ( len ( fqdn . split ( '.' ) ) == 1 ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# label = fqdn . split ( '.' ) [ 0 ] #NEWLINE# domain_name = '.' . join ( fqdn . split ( '.' ) [ 1 : ] ) #NEWLINE# search_domain = mozdns . domain . models . Domain . objects . get ( name = domain_name ) #NEWLINE# #UNINDENT# except ObjectDoesNotExist : #NEWLINE# #INDENT# search_domain = None #NEWLINE# #UNINDENT# if search_domain : #NEWLINE# #INDENT# for ( type_ , qset ) in _build_label_domain_queries ( label , search_domain , ** kwargs ) : #NEWLINE# #INDENT# if qset . exists ( ) : #NEWLINE# #INDENT# return qset