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