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