VirtualMailManager/config.py
branchv0.6.x
changeset 496 17f2c5b5098e
parent 481 90d69ae4f40d
child 568 14abdd04ddf5
equal deleted inserted replaced
495:612a60e9d558 496:17f2c5b5098e
    18 from VirtualMailManager.constants import CONF_ERROR
    18 from VirtualMailManager.constants import CONF_ERROR
    19 from VirtualMailManager.errors import ConfigError, VMMError
    19 from VirtualMailManager.errors import ConfigError, VMMError
    20 from VirtualMailManager.maillocation import known_format
    20 from VirtualMailManager.maillocation import known_format
    21 from VirtualMailManager.password import verify_scheme as _verify_scheme
    21 from VirtualMailManager.password import verify_scheme as _verify_scheme
    22 
    22 
    23 DB_MUDULES = ('psycopg2', 'pypgsql')
    23 DB_MODULES = ('psycopg2', 'pypgsql')
    24 DB_SSL_MODES = ('allow', 'disabled', 'prefer', 'require', 'verify-ca',
    24 DB_SSL_MODES = ('allow', 'disabled', 'prefer', 'require', 'verify-ca',
    25                 'verify-full')
    25                 'verify-full')
    26 
    26 
    27 _ = lambda msg: msg
    27 _ = lambda msg: msg
    28 
    28 
   438                 self._missing['misc'] = ['version: ' +\
   438                 self._missing['misc'] = ['version: ' +\
   439                         _(u"Not a valid Dovecot version: '%s'") % value]
   439                         _(u"Not a valid Dovecot version: '%s'") % value]
   440         # section database
   440         # section database
   441         db_err = []
   441         db_err = []
   442         value = self.dget('database.module').lower()
   442         value = self.dget('database.module').lower()
   443         if value not in DB_MUDULES:
   443         if value not in DB_MODULES:
   444             db_err.append('module: ' + \
   444             db_err.append('module: ' + \
   445                           _(u"Unsupported database module: '%s'") % value)
   445                           _(u"Unsupported database module: '%s'") % value)
   446         if value == 'psycopg2':
   446         if value == 'psycopg2':
   447             value = self.dget('database.sslmode')
   447             value = self.dget('database.sslmode')
   448             if value not in DB_SSL_MODES:
   448             if value not in DB_SSL_MODES:
   473     raise ConfigValueError(_(u"No such directory: %s") % get_unicode(path))
   473     raise ConfigValueError(_(u"No such directory: %s") % get_unicode(path))
   474 
   474 
   475 
   475 
   476 def check_db_module(module):
   476 def check_db_module(module):
   477     """Check if the *module* is a supported pgsql module."""
   477     """Check if the *module* is a supported pgsql module."""
   478     if module.lower() in DB_MUDULES:
   478     if module.lower() in DB_MODULES:
   479         return module
   479         return module
   480     raise ConfigValueError(_(u"Unsupported database module: '%s'") %
   480     raise ConfigValueError(_(u"Unsupported database module: '%s'") %
   481                            get_unicode(module))
   481                            get_unicode(module))
   482 
   482 
   483 
   483