VirtualMailManager/serviceset.py
changeset 594 cdbe200c0ecc
parent 568 14abdd04ddf5
child 638 0de0b9e75c9f
child 675 d24f094d1cb5
equal deleted inserted replaced
593:3dc1764c23d2 594:cdbe200c0ecc
   107         """Try to load the service_set by it's service combination."""
   107         """Try to load the service_set by it's service combination."""
   108         sql = ('SELECT ssid FROM service_set WHERE %s' %
   108         sql = ('SELECT ssid FROM service_set WHERE %s' %
   109                ' AND '.join('%s = %s' %
   109                ' AND '.join('%s = %s' %
   110                (k, str(v).upper()) for k, v in self._services.iteritems()))
   110                (k, str(v).upper()) for k, v in self._services.iteritems()))
   111         if self._sieve_col == 'managesieve':
   111         if self._sieve_col == 'managesieve':
   112             sql.replace('sieve', self._sieve_col)
   112             sql = sql.replace('sieve', self._sieve_col)
   113         dbc = self._dbh.cursor()
   113         dbc = self._dbh.cursor()
   114         dbc.execute(sql)
   114         dbc.execute(sql)
   115         result = dbc.fetchone()
   115         result = dbc.fetchone()
   116         dbc.close()
   116         dbc.close()
   117         if result:
   117         if result:
   139     def _save(self):
   139     def _save(self):
   140         """Store a new service_set in the database."""
   140         """Store a new service_set in the database."""
   141         sql = ('INSERT INTO service_set (ssid, smtp, pop3, imap, %s) ' %
   141         sql = ('INSERT INTO service_set (ssid, smtp, pop3, imap, %s) ' %
   142                (self._sieve_col,) +
   142                (self._sieve_col,) +
   143                'VALUES (%(ssid)s, %(smtp)s, %(pop3)s, %(imap)s, %(sieve)s)')
   143                'VALUES (%(ssid)s, %(smtp)s, %(pop3)s, %(imap)s, %(sieve)s)')
   144         if self._sieve_col == 'managesieve':
       
   145             sql.replace('sieve', self._sieve_col)
       
   146         self._set_ssid()
   144         self._set_ssid()
   147         values = {'ssid': self._ssid}
   145         values = {'ssid': self._ssid}
   148         values.update(self._services)
   146         values.update(self._services)
   149         dbc = self._dbh.cursor()
   147         dbc = self._dbh.cursor()
   150         dbc.execute(sql, values)
   148         dbc.execute(sql, values)