#NEWLINE# def get_default_domain( request ) : #NEWLINE# #INDENT# '\n    Gets the default domain object to use when creating Identity object.\n    Returns the domain context if is set, otherwise return the domain\n    of the logon user.\n    ' #NEWLINE# domain_id = request . session . get ( 'domain_context' , None ) #NEWLINE# domain_name = request . session . get ( 'domain_context_name' , None ) #NEWLINE# if ( ( VERSIONS . active >= 3 ) and ( not request ) ) : #NEWLINE# #INDENT# domain_id = request . user . user_domain_id #NEWLINE# try : #NEWLINE# #INDENT# domain = domain_get ( request , domain_id ) #NEWLINE# domain_name = domain . name #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# LOG . warning ( ( 'Unable to retrieve Domain: %s' % domain_id ) ) #NEWLINE# #UNINDENT# #UNINDENT# domain = base . APIDictWrapper ( { #NEWLINE# #INDENT# 'id' : domain_id , #NEWLINE# 'name' : domain_name , #NEWLINE# #UNINDENT# } ) #NEWLINE# return domain