53 |
53 |
54 def _setAddr(self): |
54 def _setAddr(self): |
55 dom = Domain(self._dbh, self._addr._domainname) |
55 dom = Domain(self._dbh, self._addr._domainname) |
56 self._gid = dom.getID() |
56 self._gid = dom.getID() |
57 if self._gid == 0: |
57 if self._gid == 0: |
58 raise VMMRE(_(u"The domain “%s” doesn't exist yet.") %\ |
58 raise VMMRE(_(u"The domain “%s” doesn't exist.") %\ |
59 self._addr._domainname, ERR.NO_SUCH_DOMAIN) |
59 self._addr._domainname, ERR.NO_SUCH_DOMAIN) |
60 |
60 |
61 def save(self): |
61 def save(self): |
62 if self._dest is None: |
62 if self._dest is None: |
63 raise VMMRE(_(u"No destination address for relocated user denoted."), |
63 raise VMMRE( |
64 ERR.RELOCATED_MISSING_DEST) |
64 _(u"No destination address specified for relocated user."), |
|
65 ERR.RELOCATED_MISSING_DEST) |
65 if self._isNew: |
66 if self._isNew: |
66 dbc = self._dbh.cursor() |
67 dbc = self._dbh.cursor() |
67 dbc.execute("INSERT INTO relocated VALUES (%s, %s, %s)", |
68 dbc.execute("INSERT INTO relocated VALUES (%s, %s, %s)", |
68 self._gid, self._addr._localpart, str(self._dest)) |
69 self._gid, self._addr._localpart, str(self._dest)) |
69 self._dbh.commit() |
70 self._dbh.commit() |
82 dbc.close() |
83 dbc.close() |
83 if destination is not None: |
84 if destination is not None: |
84 return destination[0] |
85 return destination[0] |
85 else: |
86 else: |
86 raise VMMRE( |
87 raise VMMRE( |
87 _(u"The relocated user “%s” doesn't exists.") % self._addr, |
88 _(u"The relocated user “%s” doesn't exist.") % self._addr, |
88 ERR.NO_SUCH_RELOCATED) |
89 ERR.NO_SUCH_RELOCATED) |
89 |
90 |
90 def delete(self): |
91 def delete(self): |
91 dbc = self._dbh.cursor() |
92 dbc = self._dbh.cursor() |
92 dbc.execute("DELETE FROM relocated WHERE gid = %s AND address = %s", |
93 dbc.execute("DELETE FROM relocated WHERE gid = %s AND address = %s", |