equal
deleted
inserted
replaced
8 from constants.VERSION import * |
8 from constants.VERSION import * |
9 |
9 |
10 from Exceptions import VMMTransportException |
10 from Exceptions import VMMTransportException |
11 import constants.ERROR as ERR |
11 import constants.ERROR as ERR |
12 |
12 |
13 class Transport: |
13 class Transport(object): |
14 """A wrapper class thats provide access to the transport table""" |
14 """A wrapper class that provides access to the transport table""" |
|
15 __slots__ = ('__id', '__transport', '_dbh') |
15 def __init__(self, dbh, tid=None, transport=None): |
16 def __init__(self, dbh, tid=None, transport=None): |
16 """Creates a new Transport instance. |
17 """Creates a new Transport instance. |
17 |
18 |
18 Either tid or transport must be specified. |
19 Either tid or transport must be specified. |
19 |
20 |
35 ERR.TRANSPORT_INIT) |
36 ERR.TRANSPORT_INIT) |
36 self._loadByID() |
37 self._loadByID() |
37 else: |
38 else: |
38 self.__transport = transport |
39 self.__transport = transport |
39 self._loadByName() |
40 self._loadByName() |
|
41 |
|
42 def __eq__(self, other): |
|
43 if isinstance(other, self.__class__): |
|
44 return self.__id == other.getID() |
|
45 return NotImplemented |
|
46 |
|
47 def __ne__(self, other): |
|
48 if isinstance(other, self.__class__): |
|
49 return self.__id != other.getID() |
|
50 return NotImplemented |
|
51 |
|
52 def __str__(self): |
|
53 return self.__transport |
40 |
54 |
41 def _loadByID(self): |
55 def _loadByID(self): |
42 dbc = self._dbh.cursor() |
56 dbc = self._dbh.cursor() |
43 dbc.execute('SELECT transport FROM transport WHERE tid = %s', self.__id) |
57 dbc.execute('SELECT transport FROM transport WHERE tid = %s', self.__id) |
44 result = dbc.fetchone() |
58 result = dbc.fetchone() |