VMM/{maillocation,quotalimit}: Unified object initialization code.
Simply raise a ValueError for wrong values (unknown IDs).
--- 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