VirtualMailManager/transport.py
branchv0.6.x
changeset 352 22d115376e4d
parent 321 883d5cd66498
child 360 44283818f8db
equal deleted inserted replaced
351:4bba5fb90b78 352:22d115376e4d
    67         return self._transport
    67         return self._transport
    68 
    68 
    69     def _load_by_id(self):
    69     def _load_by_id(self):
    70         """load a transport by its id from the database"""
    70         """load a transport by its id from the database"""
    71         dbc = self._dbh.cursor()
    71         dbc = self._dbh.cursor()
    72         dbc.execute('SELECT transport FROM transport WHERE tid=%s', self._tid)
    72         dbc.execute('SELECT transport FROM transport WHERE tid = %s',
       
    73                     (self._tid,))
    73         result = dbc.fetchone()
    74         result = dbc.fetchone()
    74         dbc.close()
    75         dbc.close()
    75         if result:
    76         if result:
    76             self._transport = result[0]
    77             self._transport = result[0]
    77         else:
    78         else:
    80 
    81 
    81     def _load_by_name(self):
    82     def _load_by_name(self):
    82         """Load a transport by its transport name from the database."""
    83         """Load a transport by its transport name from the database."""
    83         dbc = self._dbh.cursor()
    84         dbc = self._dbh.cursor()
    84         dbc.execute('SELECT tid FROM transport WHERE transport = %s',
    85         dbc.execute('SELECT tid FROM transport WHERE transport = %s',
    85                     self._transport)
    86                     (self._transport,))
    86         result = dbc.fetchone()
    87         result = dbc.fetchone()
    87         dbc.close()
    88         dbc.close()
    88         if result:
    89         if result:
    89             self._tid = result[0]
    90             self._tid = result[0]
    90         else:
    91         else:
    93     def _save(self):
    94     def _save(self):
    94         """Save the new transport in the database."""
    95         """Save the new transport in the database."""
    95         dbc = self._dbh.cursor()
    96         dbc = self._dbh.cursor()
    96         dbc.execute("SELECT nextval('transport_id')")
    97         dbc.execute("SELECT nextval('transport_id')")
    97         self._tid = dbc.fetchone()[0]
    98         self._tid = dbc.fetchone()[0]
    98         dbc.execute('INSERT INTO transport VALUES (%s, %s)', self._tid,
    99         dbc.execute('INSERT INTO transport VALUES (%s, %s)', (self._tid,
    99                     self._transport)
   100                     self._transport))
   100         self._dbh.commit()
   101         self._dbh.commit()
   101         dbc.close()
   102         dbc.close()
   102 
   103 
   103 del _
   104 del _