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