VirtualMailManager/Config.py
branchv0.6.x
changeset 206 da07dd944ad1
parent 204 83938336c518
child 207 95be8f62bc0c
equal deleted inserted replaced
205:bc9726c9ad85 206:da07dd944ad1
   108             return self._boolean_states[value.lower()]
   108             return self._boolean_states[value.lower()]
   109         else:
   109         else:
   110             raise ConfigValueError(_(u"Not a boolean: '%s'") %
   110             raise ConfigValueError(_(u"Not a boolean: '%s'") %
   111                                    get_unicode(value))
   111                                    get_unicode(value))
   112 
   112 
   113     def get_boolean(self, section, option):
   113     def getboolean(self, section, option):
   114         # if the setting was not written to the configuration file, it may
   114         """Returns the boolean value of the option, in the given section.
   115         # be still a boolean value - lets see
   115 
   116         if self._modified:
   116         For a boolean True, the value must be set to '1', 'on', 'yes',
   117             tmp = self.get(section, option)
   117         'true' or True. For a boolean False, the value must set to '0',
   118             assert isinstance(tmp, bool), 'Oops, not a boolean: %r' % tmp
   118         'off', 'no', 'false' or False.
       
   119         If the option has another value assigned this method will raise a
       
   120         ValueError.
       
   121         """
       
   122         # if the setting was modified it may be still a boolean value lets see
       
   123         tmp = self.get(section, option)
       
   124         if isinstance(tmp, bool):
   119             return tmp
   125             return tmp
   120         return self.getboolean(section, option)
   126         return RawConfigParser.getboolean(self, section, option)
   121 
   127 
   122     def _get_section_option(self, section_option):
   128     def _get_section_option(self, section_option):
   123         """splits ``section_option`` (section\ **.**\ option) in two parts
   129         """splits ``section_option`` (section\ **.**\ option) in two parts
   124         and returns them as list ``[section, option]``, if:
   130         and returns them as list ``[section, option]``, if:
   125 
   131 
   300 
   306 
   301         LCO = LazyConfigOption
   307         LCO = LazyConfigOption
   302         bool_t = self.bool_new
   308         bool_t = self.bool_new
   303         self._cfg = {
   309         self._cfg = {
   304             'account': {
   310             'account': {
   305                 'delete_directory': LCO(bool_t, False, self.get_boolean),
   311                 'delete_directory': LCO(bool_t, False, self.getboolean),
   306                 'directory_mode':   LCO(int,    448,   self.getint),
   312                 'directory_mode':   LCO(int,    448,   self.getint),
   307                 'disk_usage':       LCO(bool_t, False, self.get_boolean),
   313                 'disk_usage':       LCO(bool_t, False, self.getboolean),
   308                 'password_length':  LCO(int,    8,     self.getint),
   314                 'password_length':  LCO(int,    8,     self.getint),
   309                 'random_password':  LCO(bool_t, False, self.get_boolean),
   315                 'random_password':  LCO(bool_t, False, self.getboolean),
   310                 'imap' :            LCO(bool_t, True,  self.get_boolean),
   316                 'imap' :            LCO(bool_t, True,  self.getboolean),
   311                 'pop3' :            LCO(bool_t, True,  self.get_boolean),
   317                 'pop3' :            LCO(bool_t, True,  self.getboolean),
   312                 'sieve':            LCO(bool_t, True,  self.get_boolean),
   318                 'sieve':            LCO(bool_t, True,  self.getboolean),
   313                 'smtp' :            LCO(bool_t, True,  self.get_boolean),
   319                 'smtp' :            LCO(bool_t, True,  self.getboolean),
   314             },
   320             },
   315             'bin': {
   321             'bin': {
   316                 'dovecotpw': LCO(str, '/usr/sbin/dovecotpw', self.get, exec_ok),
   322                 'dovecotpw': LCO(str, '/usr/sbin/dovecotpw', self.get, exec_ok),
   317                 'du':        LCO(str, '/usr/bin/du',        self.get, exec_ok),
   323                 'du':        LCO(str, '/usr/bin/du',        self.get, exec_ok),
   318                 'postconf':  LCO(str, '/usr/sbin/postconf', self.get, exec_ok),
   324                 'postconf':  LCO(str, '/usr/sbin/postconf', self.get, exec_ok),
   322                 'name': LCO(str, 'mailsys',   self.get),
   328                 'name': LCO(str, 'mailsys',   self.get),
   323                 'pass': LCO(str, None,        self.get),
   329                 'pass': LCO(str, None,        self.get),
   324                 'user': LCO(str, None,        self.get),
   330                 'user': LCO(str, None,        self.get),
   325             },
   331             },
   326             'domain': {
   332             'domain': {
   327                 'auto_postmaster':  LCO(bool_t, True,  self.get_boolean),
   333                 'auto_postmaster':  LCO(bool_t, True,  self.getboolean),
   328                 'delete_directory': LCO(bool_t, False, self.get_boolean),
   334                 'delete_directory': LCO(bool_t, False, self.getboolean),
   329                 'directory_mode':   LCO(int,    504,   self.getint),
   335                 'directory_mode':   LCO(int,    504,   self.getint),
   330                 'force_deletion':   LCO(bool_t, False, self.get_boolean),
   336                 'force_deletion':   LCO(bool_t, False, self.getboolean),
   331             },
   337             },
   332             'maildir': {
   338             'maildir': {
   333                 'folders': LCO(str, 'Drafts:Sent:Templates:Trash', self.get),
   339                 'folders': LCO(str, 'Drafts:Sent:Templates:Trash', self.get),
   334                 'name':    LCO(str, 'Maildir',                     self.get),
   340                 'name':    LCO(str, 'Maildir',                     self.get),
   335             },
   341             },