VMM/{maillocation,quotalimit}: Unified object initialization code. v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Fri, 04 Nov 2011 23:52:49 +0000
branchv0.6.x
changeset 450 fd4aa073015f
parent 449 6826acb9b0a7
child 451 2408a3cd4bea
VMM/{maillocation,quotalimit}: Unified object initialization code. Simply raise a ValueError for wrong values (unknown IDs).
VirtualMailManager/maillocation.py
VirtualMailManager/quotalimit.py
--- a/VirtualMailManager/maillocation.py	Fri Nov 04 22:45:53 2011 +0000
+++ b/VirtualMailManager/maillocation.py	Fri Nov 04 23:52:49 2011 +0000
@@ -10,8 +10,7 @@
 
 """
 
-from VirtualMailManager.constants import \
-     MAILLOCATION_INIT, UNKNOWN_MAILLOCATION_ID
+from VirtualMailManager.constants import MAILLOCATION_INIT
 from VirtualMailManager.errors import MailLocationError as MLErr
 from VirtualMailManager.pycompat import all
 
@@ -120,8 +119,7 @@
         result = dbc.fetchone()
         dbc.close()
         if not result:
-            raise MLErr(_(u'Unknown mail_location id: %u') % mid,
-                        UNKNOWN_MAILLOCATION_ID)
+            raise ValueError('Unknown mail_location id specified: %r' % mid)
         self._mid = mid
         self._mbfmt, self._directory = result
 
--- a/VirtualMailManager/quotalimit.py	Fri Nov 04 22:45:53 2011 +0000
+++ b/VirtualMailManager/quotalimit.py	Fri Nov 04 23:52:49 2011 +0000
@@ -9,8 +9,6 @@
     for domains and accounts.
 """
 
-from VirtualMailManager.constants import VMM_ERROR
-from VirtualMailManager.errors import VMMError
 from VirtualMailManager.pycompat import all
 
 _ = lambda msg: msg
@@ -111,7 +109,7 @@
         res = dbc.fetchone()
         dbc.close()
         if not res:
-            raise VMMError(_(u'Unknown quota limit id specified.'), VMM_ERROR)
+            raise ValueError('Unknown quota limit id specified: %r' % qid)
         self._qid = qid
         self._bytes, self._messages = res