VirtualMailManager/alias.py
branchv0.6.x
changeset 352 22d115376e4d
parent 322 94bd10e237e5
child 366 d6573da35b5f
equal deleted inserted replaced
351:4bba5fb90b78 352:22d115376e4d
    39 
    39 
    40     def _load_dests(self):
    40     def _load_dests(self):
    41         """Loads all known destination addresses into the _dests list."""
    41         """Loads all known destination addresses into the _dests list."""
    42         dbc = self._dbh.cursor()
    42         dbc = self._dbh.cursor()
    43         dbc.execute('SELECT destination FROM alias WHERE gid = %s AND '
    43         dbc.execute('SELECT destination FROM alias WHERE gid = %s AND '
    44                     'address = %s', self._gid, self._addr.localpart)
    44                     'address = %s', (self._gid, self._addr.localpart))
    45         dests = dbc.fetchall()
    45         dests = dbc.fetchall()
    46         if dbc.rowcount > 0:
    46         if dbc.rowcount > 0:
    47             self._dests.extend(EmailAddress(dest[0]) for dest in dests)
    47             self._dests.extend(EmailAddress(dest[0]) for dest in dests)
    48         dbc.close()
    48         dbc.close()
    49 
    49 
    79 
    79 
    80         """
    80         """
    81         dbc = self._dbh.cursor()
    81         dbc = self._dbh.cursor()
    82         if not destination:
    82         if not destination:
    83             dbc.execute('DELETE FROM alias WHERE gid = %s AND address = %s',
    83             dbc.execute('DELETE FROM alias WHERE gid = %s AND address = %s',
    84                         self._gid, self._addr.localpart)
    84                         (self._gid, self._addr.localpart))
    85         else:
    85         else:
    86             dbc.execute('DELETE FROM alias WHERE gid = %s AND address = %s '
    86             dbc.execute('DELETE FROM alias WHERE gid = %s AND address = %s '
    87                         'AND destination = %s', self._gid,
    87                         'AND destination = %s',
    88                         self._addr.localpart, str(destination))
    88                         (self._gid, self._addr.localpart, str(destination)))
    89         if dbc.rowcount > 0:
    89         if dbc.rowcount > 0:
    90             self._dbh.commit()
    90             self._dbh.commit()
    91         dbc.close()
    91         dbc.close()
    92 
    92 
    93     def __len__(self):
    93     def __len__(self):