equal
deleted
inserted
replaced
50 `_dest` attribute. |
50 `_dest` attribute. |
51 |
51 |
52 """ |
52 """ |
53 dbc = self._dbh.cursor() |
53 dbc = self._dbh.cursor() |
54 dbc.execute('SELECT destination FROM relocated WHERE gid = %s AND ' |
54 dbc.execute('SELECT destination FROM relocated WHERE gid = %s AND ' |
55 'address = %s', self._gid, self._addr.localpart) |
55 'address = %s', (self._gid, self._addr.localpart)) |
56 destination = dbc.fetchone() |
56 destination = dbc.fetchone() |
57 dbc.close() |
57 dbc.close() |
58 if destination: |
58 if destination: |
59 self._dest = EmailAddress(destination[0]) |
59 self._dest = EmailAddress(destination[0]) |
60 |
60 |
81 self._dest = destination |
81 self._dest = destination |
82 |
82 |
83 dbc = self._dbh.cursor() |
83 dbc = self._dbh.cursor() |
84 if not update: |
84 if not update: |
85 dbc.execute('INSERT INTO relocated VALUES (%s, %s, %s)', |
85 dbc.execute('INSERT INTO relocated VALUES (%s, %s, %s)', |
86 self._gid, self._addr.localpart, str(self._dest)) |
86 (self._gid, self._addr.localpart, str(self._dest))) |
87 else: |
87 else: |
88 dbc.execute('UPDATE relocated SET destination = %s WHERE gid = %s ' |
88 dbc.execute('UPDATE relocated SET destination = %s WHERE gid = %s ' |
89 'AND address = %s', str(self._dest), self._gid, |
89 'AND address = %s', |
90 self._addr.localpart) |
90 (str(self._dest), self._gid, self._addr.localpart)) |
91 self._dbh.commit() |
91 self._dbh.commit() |
92 dbc.close() |
92 dbc.close() |
93 |
93 |
94 def get_info(self): |
94 def get_info(self): |
95 """Returns the address to which mails should be sent.""" |
95 """Returns the address to which mails should be sent.""" |
103 if not self._dest: |
103 if not self._dest: |
104 raise RErr(_(u"The relocated user '%s' doesn't exist.") % |
104 raise RErr(_(u"The relocated user '%s' doesn't exist.") % |
105 self._addr, NO_SUCH_RELOCATED) |
105 self._addr, NO_SUCH_RELOCATED) |
106 dbc = self._dbh.cursor() |
106 dbc = self._dbh.cursor() |
107 dbc.execute('DELETE FROM relocated WHERE gid = %s AND address = %s', |
107 dbc.execute('DELETE FROM relocated WHERE gid = %s AND address = %s', |
108 self._gid, self._addr.localpart) |
108 (self._gid, self._addr.localpart)) |
109 if dbc.rowcount > 0: |
109 if dbc.rowcount > 0: |
110 self._dbh.commit() |
110 self._dbh.commit() |
111 dbc.close() |
111 dbc.close() |
112 self._dest = None |
112 self._dest = None |
113 |
113 |