VirtualMailManager/transport.py
branchv0.6.x
changeset 449 6826acb9b0a7
parent 379 7518d927d443
child 568 14abdd04ddf5
--- a/VirtualMailManager/transport.py	Fri Nov 04 03:25:29 2011 +0000
+++ b/VirtualMailManager/transport.py	Fri Nov 04 22:45:53 2011 +0000
@@ -9,8 +9,6 @@
     domains and accounts.
 """
 
-from VirtualMailManager.constants import UNKNOWN_TRANSPORT_ID
-from VirtualMailManager.errors import TransportError
 from VirtualMailManager.pycompat import any
 
 _ = lambda msg: msg
@@ -33,11 +31,11 @@
 
         """
         self._dbh = dbh
+        self._tid = 0
         assert any((tid, transport))
         if tid:
             assert not isinstance(tid, bool) and isinstance(tid, (int, long))
-            self._tid = tid
-            self._load_by_id()
+            self._load_by_id(tid)
         else:
             assert isinstance(transport, basestring)
             self._transport = transport
@@ -66,18 +64,16 @@
     def __str__(self):
         return self._transport
 
-    def _load_by_id(self):
+    def _load_by_id(self, tid):
         """load a transport by its id from the database"""
         dbc = self._dbh.cursor()
-        dbc.execute('SELECT transport FROM transport WHERE tid = %s',
-                    (self._tid,))
+        dbc.execute('SELECT transport FROM transport WHERE tid = %s', (tid,))
         result = dbc.fetchone()
         dbc.close()
-        if result:
-            self._transport = result[0]
-        else:
-            raise TransportError(_(u'Unknown transport id specified.'),
-                                 UNKNOWN_TRANSPORT_ID)
+        if not result:
+            raise ValueError('Unknown transport id specified: %r' % tid)
+        self._transport = result[0]
+        self._tid = tid
 
     def _load_by_name(self):
         """Load a transport by its transport name from the database."""