VirtualMailManager/Domain.py
changeset 18 c98e08791ee8
parent 9 e3d3dbeb5b84
child 24 48ea255e8a85
equal deleted inserted replaced
17:fe9be0081e5f 18:c98e08791ee8
   151             dbc.close()
   151             dbc.close()
   152         else:
   152         else:
   153             raise VMMDomainException(("Domain doesn't exist yet.",
   153             raise VMMDomainException(("Domain doesn't exist yet.",
   154                 ERR.NO_SUCH_DOMAIN))
   154                 ERR.NO_SUCH_DOMAIN))
   155 
   155 
   156     def updateTransport(self, transport):
   156     def updateTransport(self, transport, force = False):
   157         """Sets a new transport for the domain.
   157         """Sets a new transport for the domain.
   158 
   158 
   159         Keyword arguments:
   159         Keyword arguments:
   160         transport -- the new transport (str)
   160         transport -- the new transport (str)
       
   161         force -- True/False force new transport for all accounts (bool)
   161         """
   162         """
   162         if self._id > 0:
   163         if self._id > 0:
   163             trsp = Transport(self._dbh, transport=transport)
   164             trsp = Transport(self._dbh, transport=transport)
   164             dbc = self._dbh.cursor()
   165             dbc = self._dbh.cursor()
   165             dbc.execute("UPDATE domains SET tid=%s WHERE gid=%s", trsp.getID(),
   166             dbc.execute("UPDATE domains SET tid=%s WHERE gid=%s", trsp.getID(),
   166                     self._id)
   167                     self._id)
   167             if dbc.rowcount > 0:
   168             if dbc.rowcount > 0:
   168                 self._dbh.commit()
   169                 self._dbh.commit()
       
   170             if force:
       
   171                 dbc.execute("UPDATE users SET tid=%s WHERE gid=%s",
       
   172                         trsp.getID(), self._id)
       
   173                 if dbc.rowcount > 0:
       
   174                     self._dbh.commit()
   169             dbc.close()
   175             dbc.close()
   170         else:
   176         else:
   171             raise VMMDomainException(("Domain doesn't exist yet.",
   177             raise VMMDomainException(("Domain doesn't exist yet.",
   172                 ERR.NO_SUCH_DOMAIN))
   178                 ERR.NO_SUCH_DOMAIN))
   173 
   179