VMM/{account,handler}: Account delete, use the boolean keyword force too. v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Fri, 30 Jul 2010 19:14:49 +0000
branchv0.6.x
changeset 333 1ed85e696748
parent 332 352ca7f1b332
child 334 3f550826b1cc
VMM/{account,handler}: Account delete, use the boolean keyword force too.
VirtualMailManager/account.py
VirtualMailManager/handler.py
man/de/man1/vmm.1.rst
man/man1/vmm.1.rst
--- a/VirtualMailManager/account.py	Fri Jul 30 15:51:22 2010 +0000
+++ b/VirtualMailManager/account.py	Fri Jul 30 19:14:49 2010 +0000
@@ -348,20 +348,21 @@
             aliases = [alias[0] for alias in addresses]
         return aliases
 
-    def delete(self, delalias=False):
+    def delete(self, force=False):
         """Delete the Account from the database.
 
         Argument:
 
-        `delalias` : bool
-          if *delalias* is `True`, all aliases, which points to the Account,
-          will be also deleted.  If there are aliases and *delalias* is
+        `force` : bool
+          if *force* is `True`, all aliases, which points to the Account,
+          will be also deleted.  If there are aliases and *force* is
           `False`, an AccountError will be raised.
         """
-        assert isinstance(delalias, bool)
+        if not isinstance(force, bool):
+            raise TypeError('force must be a bool')
         self._chk_state()
         dbc = self._dbh.cursor()
-        if delalias:
+        if force:
             dbc.execute('DELETE FROM users WHERE uid = %s', self._uid)
             # delete also all aliases where the destination address is the same
             # as for this account.
--- a/VirtualMailManager/handler.py	Fri Jul 30 15:51:22 2010 +0000
+++ b/VirtualMailManager/handler.py	Fri Jul 30 19:14:49 2010 +0000
@@ -525,11 +525,10 @@
                 self._warnings.append(_(u"The destination account/alias '%s' "
                                         u"doesn't exist.") % destination)
 
-    def user_delete(self, emailaddress, force=None):
+    def user_delete(self, emailaddress, force=False):
         """Wrapper around Account.delete(...)"""
-        if force not in (None, 'delalias'):
-            raise VMMError(_(u"Invalid argument: '%s'") % force,
-                           INVALID_ARGUMENT)
+        if not isinstance(force, bool):
+            raise TypeError('force must be a bool')
         acc = self._get_account(emailaddress)
         if not acc:
             raise VMMError(_(u"The account '%s' doesn't exist.") %
@@ -538,7 +537,7 @@
         gid = acc.gid
         dom_dir = acc.domain.directory
         acc_dir = acc.home
-        acc.delete(bool(force))
+        acc.delete(force)
         if self._cfg.dget('account.delete_directory'):
             try:
                 self._delete_home(dom_dir, uid, gid)
@@ -548,9 +547,8 @@
                     warning = _(u"""\
 The account has been successfully deleted from the database.
     But an error occurred while deleting the following directory:
-    “%(directory)s”
-    Reason: %(reason)s""") % \
-                                {'directory': acc_dir, 'reason': err.msg}
+    '%(directory)s'
+    Reason: %(reason)s""") % {'directory': acc_dir, 'reason': err.msg}
                     self._warnings.append(warning)
                 else:
                     raise
--- a/man/de/man1/vmm.1.rst	Fri Jul 30 15:51:22 2010 +0000
+++ b/man/de/man1/vmm.1.rst	Fri Jul 30 19:14:49 2010 +0000
@@ -358,14 +358,14 @@
 
 .. _userdelete:
 
-``userdelete (ud) Adresse [ delalias ]``
+``userdelete (ud) Adresse [ force ]``
   Verwenden Sie diesen Unterbefehl um, das Konto mit der angegebenen
   *Adresse* zu löschen.
 
   Sollte es einen oder mehrere Aliase geben, deren Zieladresse mit der
   *Adresse* des zu löschenden Kontos identisch ist, wird **vmm** die
   Ausführung des Befehls mit einer entsprechenden Fehlermeldung beenden. Um
-  dieses zu umgehen, kann das optionale Schlüsselwort **delalias**
+  dieses zu umgehen, kann das optionale Schlüsselwort **force**
   angegebenen werden.
 
 
--- a/man/man1/vmm.1.rst	Fri Jul 30 15:51:22 2010 +0000
+++ b/man/man1/vmm.1.rst	Fri Jul 30 19:14:49 2010 +0000
@@ -334,12 +334,12 @@
 
 .. _userdelete:
 
-``userdelete (ud) address [ delalias ]``
+``userdelete (ud) address [ force ]``
   Use this subcommand to delete the account with the given *address*.
 
   If there are one or more aliases with an identical destination *address*,
   **vmm** will abort the requested operation and show an error message. To
-  prevent this, specify the optional keyword **delalias**.
+  prevent this, specify the optional keyword **force**.
 
 
 ALIAS SUBCOMMANDS