equal
deleted
inserted
replaced
35 tid -- the id of a transport (long) |
35 tid -- the id of a transport (long) |
36 transport -- the value of the transport (str) |
36 transport -- the value of the transport (str) |
37 """ |
37 """ |
38 self._dbh = dbh |
38 self._dbh = dbh |
39 if tid is None and transport is None: |
39 if tid is None and transport is None: |
40 raise VMMTransportException( |
40 raise VMMTransportException(( |
41 ('Either tid or transport must be specified.', |
41 _('Either tid or transport must be specified.'), |
42 ERR.TRANSPORT_INIT)) |
42 ERR.TRANSPORT_INIT)) |
43 elif tid is not None: |
43 elif tid is not None: |
44 try: |
44 try: |
45 self.__id = long(tid) |
45 self.__id = long(tid) |
46 except ValueError: |
46 except ValueError: |
47 raise VMMTransportException(('tid must be an int/long.', |
47 raise VMMTransportException((_('tid must be an int/long.'), |
48 ERR.TRANSPORT_INIT)) |
48 ERR.TRANSPORT_INIT)) |
49 self._loadByID() |
49 self._loadByID() |
50 else: |
50 else: |
51 self.__transport = transport |
51 self.__transport = transport |
52 self._loadByName() |
52 self._loadByName() |
57 result = dbc.fetchone() |
57 result = dbc.fetchone() |
58 dbc.close() |
58 dbc.close() |
59 if result is not None: |
59 if result is not None: |
60 self.__transport = result[0] |
60 self.__transport = result[0] |
61 else: |
61 else: |
62 raise VMMTransportException(('Unknown tid specified.', |
62 raise VMMTransportException((_('Unknown tid specified.'), |
63 ERR.UNKNOWN_TRANSPORT_ID)) |
63 ERR.UNKNOWN_TRANSPORT_ID)) |
64 |
64 |
65 def _loadByName(self): |
65 def _loadByName(self): |
66 dbc = self._dbh.cursor() |
66 dbc = self._dbh.cursor() |
67 dbc.execute('SELECT tid FROM transport WHERE transport = %s', |
67 dbc.execute('SELECT tid FROM transport WHERE transport = %s', |