VirtualMailManager/AliasDomain.py
branchv0.6.x
changeset 257 5b8fde01e4f0
parent 254 8aecc83a0d32
child 290 e2785e04f92e
equal deleted inserted replaced
256:ae80282301a3 257:5b8fde01e4f0
    78         dbc = self._dbh.cursor()
    78         dbc = self._dbh.cursor()
    79         dbc.execute('INSERT INTO domain_name VALUES (%s, %s, FALSE)',
    79         dbc.execute('INSERT INTO domain_name VALUES (%s, %s, FALSE)',
    80                     self._name, self._domain.gid)
    80                     self._name, self._domain.gid)
    81         self._dbh.commit()
    81         self._dbh.commit()
    82         dbc.close()
    82         dbc.close()
       
    83         self._gid = self._domain.gid
    83 
    84 
    84     def info(self):
    85     def info(self):
    85         """Returns a dict (keys: "alias" and "domain") with the names of the
    86         """Returns a dict (keys: "alias" and "domain") with the names of the
    86         AliasDomain and its primary domain."""
    87         AliasDomain and its primary domain."""
    87         if self._gid < 1:
    88         if self._gid < 1:
   122         dbc.execute('UPDATE domain_name SET gid = %s WHERE gid = %s\
   123         dbc.execute('UPDATE domain_name SET gid = %s WHERE gid = %s\
   123  AND domainname = %s AND NOT is_primary',
   124  AND domainname = %s AND NOT is_primary',
   124                     self._domain.gid, self._gid, self._name)
   125                     self._domain.gid, self._gid, self._name)
   125         self._dbh.commit()
   126         self._dbh.commit()
   126         dbc.close()
   127         dbc.close()
       
   128         self._gid = self._domain.gid
   127 
   129 
   128     def delete(self):
   130     def delete(self):
   129         """Delete the AliasDomain's record form the database.
   131         """Delete the AliasDomain's record form the database.
   130 
   132 
   131         Raises an AliasDomainError if the AliasDomain doesn't exist.
   133         Raises an AliasDomainError if the AliasDomain doesn't exist.
   137         dbc.execute(
   139         dbc.execute(
   138             'DELETE FROM domain_name WHERE domainname = %s AND NOT is_primary',
   140             'DELETE FROM domain_name WHERE domainname = %s AND NOT is_primary',
   139                     self._name)
   141                     self._name)
   140         if dbc.rowcount > 0:
   142         if dbc.rowcount > 0:
   141             self._dbh.commit()
   143             self._dbh.commit()
       
   144             self._gid = 0
       
   145         dbc.close()
   142 
   146 
   143 
   147 
   144 del _
   148 del _