VirtualMailManager/handler.py
branchv0.6.x
changeset 371 3b2fd0b4e51b
parent 366 d6573da35b5f
child 372 ef99be5b7ec0
equal deleted inserted replaced
370:1b1f8f0cc687 371:3b2fd0b4e51b
    28      DATABASE_ERROR, DOMAINDIR_GROUP_MISMATCH, DOMAIN_INVALID, \
    28      DATABASE_ERROR, DOMAINDIR_GROUP_MISMATCH, DOMAIN_INVALID, \
    29      FOUND_DOTS_IN_PATH, INVALID_ARGUMENT, MAILDIR_PERM_MISMATCH, \
    29      FOUND_DOTS_IN_PATH, INVALID_ARGUMENT, MAILDIR_PERM_MISMATCH, \
    30      NOT_EXECUTABLE, NO_SUCH_ACCOUNT, NO_SUCH_ALIAS, NO_SUCH_BINARY, \
    30      NOT_EXECUTABLE, NO_SUCH_ACCOUNT, NO_SUCH_ALIAS, NO_SUCH_BINARY, \
    31      NO_SUCH_DIRECTORY, NO_SUCH_RELOCATED, RELOCATED_EXISTS, VMM_ERROR
    31      NO_SUCH_DIRECTORY, NO_SUCH_RELOCATED, RELOCATED_EXISTS, VMM_ERROR
    32 from VirtualMailManager.domain import Domain, get_gid
    32 from VirtualMailManager.domain import Domain, get_gid
    33 from VirtualMailManager.emailaddress import EmailAddress
    33 from VirtualMailManager.emailaddress import DestinationEmailAddress, \
       
    34      EmailAddress
    34 from VirtualMailManager.errors import \
    35 from VirtualMailManager.errors import \
    35      DomainError, NotRootError, PermissionError, VMMError
    36      DomainError, NotRootError, PermissionError, VMMError
    36 from VirtualMailManager.mailbox import new as new_mailbox
    37 from VirtualMailManager.mailbox import new as new_mailbox
    37 from VirtualMailManager.pycompat import all, any
    38 from VirtualMailManager.pycompat import all, any
    38 from VirtualMailManager.relocated import Relocated
    39 from VirtualMailManager.relocated import Relocated
   555 
   556 
   556     def alias_add(self, aliasaddress, *targetaddresses):
   557     def alias_add(self, aliasaddress, *targetaddresses):
   557         """Creates a new `Alias` entry for the given *aliasaddress* with
   558         """Creates a new `Alias` entry for the given *aliasaddress* with
   558         the given *targetaddresses*."""
   559         the given *targetaddresses*."""
   559         alias = self._get_alias(aliasaddress)
   560         alias = self._get_alias(aliasaddress)
   560         destinations = [EmailAddress(address) for address in targetaddresses]
   561         destinations = [DestinationEmailAddress(addr, self._dbh) \
       
   562                 for addr in targetaddresses]
   561         warnings = []
   563         warnings = []
   562         destinations = alias.add_destinations(destinations, warnings)
   564         destinations = alias.add_destinations(destinations, warnings)
   563         if warnings:
   565         if warnings:
   564             self._warnings.append(_('Ignored destination addresses:'))
   566             self._warnings.append(_('Ignored destination addresses:'))
   565             self._warnings.extend(('  * %s' % w for w in warnings))
   567             self._warnings.extend(('  * %s' % w for w in warnings))
   566         for destination in destinations:
   568         for destination in destinations:
   567             if get_gid(self._dbh, destination.domainname) and \
   569             if destination.gid and \
   568                not self._chk_other_address_types(destination, TYPE_RELOCATED):
   570                not self._chk_other_address_types(destination, TYPE_RELOCATED):
   569                 self._warnings.append(_(u"The destination account/alias '%s' "
   571                 self._warnings.append(_(u"The destination account/alias '%s' "
   570                                         u"doesn't exist.") % destination)
   572                                         u"doesn't exist.") % destination)
   571 
   573 
   572     def user_delete(self, emailaddress, force=False):
   574     def user_delete(self, emailaddress, force=False):
   704     def relocated_add(self, emailaddress, targetaddress):
   706     def relocated_add(self, emailaddress, targetaddress):
   705         """Creates a new `Relocated` entry in the database. If there is
   707         """Creates a new `Relocated` entry in the database. If there is
   706         already a relocated user with the given *emailaddress*, only the
   708         already a relocated user with the given *emailaddress*, only the
   707         *targetaddress* for the relocated user will be updated."""
   709         *targetaddress* for the relocated user will be updated."""
   708         relocated = self._get_relocated(emailaddress)
   710         relocated = self._get_relocated(emailaddress)
   709         relocated.set_destination(EmailAddress(targetaddress))
   711         relocated.set_destination(DestinationEmailAddress(targetaddress,
       
   712                                                           self._dbh))
   710 
   713 
   711     def relocated_info(self, emailaddress):
   714     def relocated_info(self, emailaddress):
   712         """Returns the target address of the relocated user with the given
   715         """Returns the target address of the relocated user with the given
   713         *emailaddress*."""
   716         *emailaddress*."""
   714         relocated = self._get_relocated(emailaddress)
   717         relocated = self._get_relocated(emailaddress)