Improve config to be Python3 compatible
issue4662 review14131002
This commit is contained in:
1 parent
637da8d22c
commit
58b357b55f
3 files changed
+18
-11
No files matched your search
@@ -9,7 +9,7 @@ __all__ = ['name', 'get']
|
||||
|
||||
|
||||
def name():
|
||||
return urlparse.urlparse(config.get('database', 'uri', '')).scheme
|
||||
return urlparse.urlparse(config.get('database', 'uri', default='')).scheme
|
||||
|
||||
|
||||
def get(prop):
|
||||
|
||||
@@ -70,8 +70,8 @@ class Database(DatabaseInterface):
|
||||
name = "dbname=%s" % self.database_name
|
||||
user = uri.username and "user=%s" % uri.username or ''
|
||||
password = uri.password and "password=%s" % uri.password or ''
|
||||
minconn = config.getint('database', 'minconn', 1)
|
||||
maxconn = config.getint('database', 'maxconn', 64)
|
||||
minconn = config.getint('database', 'minconn', default=1)
|
||||
maxconn = config.getint('database', 'maxconn', default=64)
|
||||
dsn = '%s %s %s %s %s' % (host, port, name, user, password)
|
||||
self._connpool = ThreadedConnectionPool(minconn, maxconn, dsn)
|
||||
return self
|
||||
|
||||
+15
-8
@@ -69,30 +69,37 @@ class TrytonConfigParser(ConfigParser.RawConfigParser):
|
||||
return
|
||||
self.read(configfile)
|
||||
|
||||
def get(self, section, option, default=None):
|
||||
def get(self, section, option, *args, **kwargs):
|
||||
default = kwargs.pop('default', None)
|
||||
try:
|
||||
return ConfigParser.RawConfigParser.get(self, section, option)
|
||||
return ConfigParser.RawConfigParser.get(self, section, option,
|
||||
*args, **kwargs)
|
||||
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError):
|
||||
return default
|
||||
|
||||
def getint(self, section, option, default=None):
|
||||
def getint(self, section, option, *args, **kwargs):
|
||||
default = kwargs.pop('default', None)
|
||||
try:
|
||||
return ConfigParser.RawConfigParser.getint(self, section, option)
|
||||
return ConfigParser.RawConfigParser.getint(self, section, option,
|
||||
*args, **kwargs)
|
||||
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError,
|
||||
TypeError):
|
||||
return default
|
||||
|
||||
def getfloat(self, section, option, default=None):
|
||||
def getfloat(self, section, option, *args, **kwargs):
|
||||
default = kwargs.pop('default', None)
|
||||
try:
|
||||
return ConfigParser.RawConfigParser.getfloat(self, section, option)
|
||||
return ConfigParser.RawConfigParser.getfloat(self, section, option,
|
||||
*args, **kwargs)
|
||||
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError,
|
||||
TypeError):
|
||||
return default
|
||||
|
||||
def getboolean(self, section, option, default=None):
|
||||
def getboolean(self, section, option, *args, **kwargs):
|
||||
default = kwargs.pop('default', None)
|
||||
try:
|
||||
return ConfigParser.RawConfigParser.getboolean(
|
||||
self, section, option)
|
||||
self, section, option, *args, **kwargs)
|
||||
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError,
|
||||
AttributeError):
|
||||
return default
|
||||
|
||||
Reference in new issue
Block a user