equal
deleted
inserted
replaced
59 self._id, self._domaindir = result[0], result[2] |
59 self._id, self._domaindir = result[0], result[2] |
60 self._transport = Transport(self._dbh, tid=result[1]) |
60 self._transport = Transport(self._dbh, tid=result[1]) |
61 return True |
61 return True |
62 else: |
62 else: |
63 return False |
63 return False |
64 |
|
65 def _aliasExists(self, aliasname): |
|
66 aliasname = VMM.VirtualMailManager.chkDomainname(aliasname) |
|
67 dbc = self._dbh.cursor() |
|
68 dbc.execute("SELECT gid, is_primary FROM domain_name\ |
|
69 WHERE domainname = %s", aliasname) |
|
70 result = dbc.fetchone() |
|
71 dbc.close() |
|
72 if result is None: |
|
73 return False |
|
74 elif result[1]: |
|
75 raise VMMDE(_(u'The domain »%s« already exists.') % self._name, |
|
76 ERR.DOMAIN_EXISTS) |
|
77 else: |
|
78 raise VMMDE(_(u'The domain alias »%s« already exists.') % aliasname, |
|
79 ERR.DOMAIN_ALIAS_EXISTS) |
|
80 |
64 |
81 def _setID(self): |
65 def _setID(self): |
82 """Sets the ID of the domain.""" |
66 """Sets the ID of the domain.""" |
83 dbc = self._dbh.cursor() |
67 dbc = self._dbh.cursor() |
84 dbc.execute("SELECT nextval('domain_gid')") |
68 dbc.execute("SELECT nextval('domain_gid')") |
188 if force: |
172 if force: |
189 dbc.execute("UPDATE users SET tid = %s WHERE gid = %s", |
173 dbc.execute("UPDATE users SET tid = %s WHERE gid = %s", |
190 trsp.getID(), self._id) |
174 trsp.getID(), self._id) |
191 if dbc.rowcount > 0: |
175 if dbc.rowcount > 0: |
192 self._dbh.commit() |
176 self._dbh.commit() |
193 dbc.close() |
|
194 else: |
|
195 raise VMMDE(_(u"The domain »%s« doesn't exist yet.") % self._name, |
|
196 ERR.NO_SUCH_DOMAIN) |
|
197 |
|
198 def saveAlias(self, aliasname): |
|
199 """Stores the alias name for the domain in the database. |
|
200 |
|
201 Keyword arguments: |
|
202 aliasname -- the alias name of the domain (str) |
|
203 """ |
|
204 aliasname = VMM.VirtualMailManager.chkDomainname(aliasname) |
|
205 if self._id > 0 and not self._aliasExists(aliasname): |
|
206 dbc = self._dbh.cursor() |
|
207 dbc.execute('INSERT INTO domain_name VALUES (%s, %s, %s)', |
|
208 aliasname, self._id, False) |
|
209 if dbc.rowcount == 1: |
|
210 self._dbh.commit() |
|
211 dbc.close() |
177 dbc.close() |
212 else: |
178 else: |
213 raise VMMDE(_(u"The domain »%s« doesn't exist yet.") % self._name, |
179 raise VMMDE(_(u"The domain »%s« doesn't exist yet.") % self._name, |
214 ERR.NO_SUCH_DOMAIN) |
180 ERR.NO_SUCH_DOMAIN) |
215 |
181 |
317 except KeyError: |
283 except KeyError: |
318 domdict[gid] = [None, dom] |
284 domdict[gid] = [None, dom] |
319 del doms |
285 del doms |
320 return order, domdict |
286 return order, domdict |
321 |
287 |
322 def deleteAlias(dbh, aliasname): |
|
323 aliasname = VMM.VirtualMailManager.chkDomainname(aliasname) |
|
324 dbc = dbh.cursor() |
|
325 dbc.execute('DELETE FROM domain_name WHERE domainname = %s', aliasname) |
|
326 if dbc.rowcount > 0: |
|
327 dbh.commit() |
|
328 dbc.close() |
|
329 |
|