1 # Copyright (C) 1998-2008 by the Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 from types import StringType, TupleType
25 from Mailman import ExternalConnector
27 from Mailman import mm_cfg
28 from Mailman import Utils
29 from Mailman.Logging.Syslog import syslog
33 class PsycopgConnector(ExternalConnector.ExternalConnector):
34 def __init__(self,mlist,param):
35 ExternalConnector.ExternalConnector.__init__(self,mlist,param)
36 def __db_connect__(self):
37 if mm_cfg.connection == 0:
42 if self._param['dbhost']<> "127.0.0.1" and self._param['dbhost']<> "127.0.1.1" and self._param['dbhost']<> "":
43 connection = psycopg2.connect (host = self._param['dbhost'], user = self._param['dbuser'], password = self._param['dbpassword'], database = self._param['database'])
45 connection = psycopg2.connect (user = self._param['dbuser'], password = self._param['dbpassword'], database = self._param['database'])
46 mm_cfg.connection = connection
47 mm_cfg.cursor=connection.cursor()