VirtualMailManager/handler.py
branchv0.6.x
changeset 333 1ed85e696748
parent 331 270b57af85de
child 335 7a471cace3ba
equal deleted inserted replaced
332:352ca7f1b332 333:1ed85e696748
   523             if get_gid(self._dbh, destination.domainname) and \
   523             if get_gid(self._dbh, destination.domainname) and \
   524                not self._chk_other_address_types(destination, TYPE_RELOCATED):
   524                not self._chk_other_address_types(destination, TYPE_RELOCATED):
   525                 self._warnings.append(_(u"The destination account/alias '%s' "
   525                 self._warnings.append(_(u"The destination account/alias '%s' "
   526                                         u"doesn't exist.") % destination)
   526                                         u"doesn't exist.") % destination)
   527 
   527 
   528     def user_delete(self, emailaddress, force=None):
   528     def user_delete(self, emailaddress, force=False):
   529         """Wrapper around Account.delete(...)"""
   529         """Wrapper around Account.delete(...)"""
   530         if force not in (None, 'delalias'):
   530         if not isinstance(force, bool):
   531             raise VMMError(_(u"Invalid argument: '%s'") % force,
   531             raise TypeError('force must be a bool')
   532                            INVALID_ARGUMENT)
       
   533         acc = self._get_account(emailaddress)
   532         acc = self._get_account(emailaddress)
   534         if not acc:
   533         if not acc:
   535             raise VMMError(_(u"The account '%s' doesn't exist.") %
   534             raise VMMError(_(u"The account '%s' doesn't exist.") %
   536                            acc.address, NO_SUCH_ACCOUNT)
   535                            acc.address, NO_SUCH_ACCOUNT)
   537         uid = acc.uid
   536         uid = acc.uid
   538         gid = acc.gid
   537         gid = acc.gid
   539         dom_dir = acc.domain.directory
   538         dom_dir = acc.domain.directory
   540         acc_dir = acc.home
   539         acc_dir = acc.home
   541         acc.delete(bool(force))
   540         acc.delete(force)
   542         if self._cfg.dget('account.delete_directory'):
   541         if self._cfg.dget('account.delete_directory'):
   543             try:
   542             try:
   544                 self._delete_home(dom_dir, uid, gid)
   543                 self._delete_home(dom_dir, uid, gid)
   545             except VMMError, err:
   544             except VMMError, err:
   546                 if err.code in (FOUND_DOTS_IN_PATH, MAILDIR_PERM_MISMATCH,
   545                 if err.code in (FOUND_DOTS_IN_PATH, MAILDIR_PERM_MISMATCH,
   547                                 NO_SUCH_DIRECTORY):
   546                                 NO_SUCH_DIRECTORY):
   548                     warning = _(u"""\
   547                     warning = _(u"""\
   549 The account has been successfully deleted from the database.
   548 The account has been successfully deleted from the database.
   550     But an error occurred while deleting the following directory:
   549     But an error occurred while deleting the following directory:
   551     ā€œ%(directory)sā€
   550     '%(directory)s'
   552     Reason: %(reason)s""") % \
   551     Reason: %(reason)s""") % {'directory': acc_dir, 'reason': err.msg}
   553                                 {'directory': acc_dir, 'reason': err.msg}
       
   554                     self._warnings.append(warning)
   552                     self._warnings.append(warning)
   555                 else:
   553                 else:
   556                     raise
   554                     raise
   557 
   555 
   558     def alias_info(self, aliasaddress):
   556     def alias_info(self, aliasaddress):