equal
deleted
inserted
replaced
33 assert isinstance(address, EmailAddress) |
33 assert isinstance(address, EmailAddress) |
34 self._addr = address |
34 self._addr = address |
35 self._dbh = dbh |
35 self._dbh = dbh |
36 self._gid = get_gid(self._dbh, self._addr.domainname) |
36 self._gid = get_gid(self._dbh, self._addr.domainname) |
37 if not self._gid: |
37 if not self._gid: |
38 raise RErr(_(u"The domain '%s' doesn't exist.") % |
38 raise RErr(_(u"The domain '%s' does not exist.") % |
39 self._addr.domainname, NO_SUCH_DOMAIN) |
39 self._addr.domainname, NO_SUCH_DOMAIN) |
40 self._dest = None |
40 self._dest = None |
41 |
41 |
42 self._load() |
42 self._load() |
43 |
43 |
93 dbc.close() |
93 dbc.close() |
94 |
94 |
95 def get_info(self): |
95 def get_info(self): |
96 """Returns the address to which mails should be sent.""" |
96 """Returns the address to which mails should be sent.""" |
97 if not self._dest: |
97 if not self._dest: |
98 raise RErr(_(u"The relocated user '%s' doesn't exist.") % |
98 raise RErr(_(u"The relocated user '%s' does not exist.") % |
99 self._addr, NO_SUCH_RELOCATED) |
99 self._addr, NO_SUCH_RELOCATED) |
100 return self._dest |
100 return self._dest |
101 |
101 |
102 def delete(self): |
102 def delete(self): |
103 """Deletes the relocated entry from the database.""" |
103 """Deletes the relocated entry from the database.""" |
104 if not self._dest: |
104 if not self._dest: |
105 raise RErr(_(u"The relocated user '%s' doesn't exist.") % |
105 raise RErr(_(u"The relocated user '%s' does not exist.") % |
106 self._addr, NO_SUCH_RELOCATED) |
106 self._addr, NO_SUCH_RELOCATED) |
107 dbc = self._dbh.cursor() |
107 dbc = self._dbh.cursor() |
108 dbc.execute('DELETE FROM relocated WHERE gid = %s AND address = %s', |
108 dbc.execute('DELETE FROM relocated WHERE gid = %s AND address = %s', |
109 (self._gid, self._addr.localpart)) |
109 (self._gid, self._addr.localpart)) |
110 if dbc.rowcount > 0: |
110 if dbc.rowcount > 0: |