#NEWLINE# def set_recipients( self , address_list ) : #NEWLINE# #INDENT# 'Set recipients for this alias. Special recipients:\n\n        * local mailbox + extension: r_mailbox will be set to local mailbox\n        * alias address == recipient address: valid only to keep local copies\n          (when a forward is defined) and to create exceptions when a catchall\n          is defined on the associated domain\n\n        ' #NEWLINE# to_create = [ ] #NEWLINE# for address in set ( address_list ) : #NEWLINE# #INDENT# if ( not address ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if self . aliasrecipient_set . filter ( address = address ) . exists ( ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ( local_part , domname , extension ) = split_mailbox ( address , return_extension = True ) #NEWLINE# if ( domname is None ) : #NEWLINE# #INDENT# raise BadRequest ( ( '%s %s' % ( _ ( 'Invalid address' ) , address ) ) ) #NEWLINE# #UNINDENT# domain = Domain . objects . filter ( name = domname ) . first ( ) #NEWLINE# kwargs = { #NEWLINE# #INDENT# 'address' : address , #NEWLINE# 'alias' : self , #NEWLINE# #UNINDENT# } #NEWLINE# if ( ( domain is not None ) and ( any ( ( r [ 1 ] for r in signals . use_external_recipients . send ( self , recipients = address ) ) ) is False ) ) : #NEWLINE# #INDENT# rcpt = Mailbox . objects . filter ( domain = domain , address = local_part ) . first ( ) #NEWLINE# if ( rcpt is None ) : #NEWLINE# #INDENT# rcpt = Alias . objects . filter ( address = ( '%s@%s' % ( local_part , domname ) ) ) . first ( ) #NEWLINE# if ( rcpt is None ) : #NEWLINE# #INDENT# raise NotFound ( _ ( 'Local recipient {}@{} not found' ) . format ( local_part , to_create ) ) #NEWLINE# #UNINDENT# if ( rcpt . address == self . address ) : #NEWLINE# #INDENT# raise Conflict #NEWLINE# #UNINDENT# kwargs [ 'r_alias' ] = rcpt #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# kwargs [ 'r_mailbox' ] = rcpt #NEWLINE# #UNINDENT# #UNINDENT# to_create . append ( AliasRecipient ( ** kwargs ) ) #NEWLINE# #UNINDENT# AliasRecipient . objects . bulk_create ( to_create ) #NEWLINE# self . aliasrecipient_set . exclude ( address__in = address_list ) . delete ( )