Comment 3 for bug 250643

Revision history for this message
Adam Rooke (abelianr) wrote : Re: [Bug 250643] Re: New config items break existing config files

I'm not sure how best to deal with this really.

I didn't realise config parser could write straight to a file? I know when I
was implementing it, it just manipulated strings and we then wrote the
changes to the file.

Since the config file is so basic I see no real harm having a try/except and
then adding the default config options to the file if they are missing. Or,
we could have a message that reads "your config file is out of date, do you
want to update it to the latest version or change it yourself" to give the
user some choice. Its basically a question of whether we change their config
file automatically, ask for their permission, or get them to do it.

Before that is implemented, maybe you could add something to your error code
so that a config error is captured and tells the person what to do?

2008/7/22 tiax <email address hidden>:

> we should make that process a little more robust. Missing configuration
> items should be filled with defaults. Abstracting away from the method
> we use to write default configs (i.e. switching to ConfigParser here,
> too) and a try/except clause should allow us to complete existing config
> files with missing items, so we won't fall into this pit with every new
> config item we add
>
> ** Summary changed:
>
> - Programming error in current trunk
> + New config items break existing config files
>
> --
> New config items break existing config files
> https://bugs.launchpad.net/bugs/250643
> You received this bug notification because you are a member of PyRoom
> Bug Squad, which is subscribed to PyRoom.
>
> Status in PyRoom: distraction-free writing: New
>
> Bug description:
> When trying to run pyroom trunk version (from 2 minutes ago) I get this:
>
> Traceback (most recent call last):
>
> File "pyroom.py", line 89, in <module>
> pyroom = BasicEdit(style=style, pyroom_config=pyroom_config)
>
> File "/home/swizec/pyroom/basic_edit.py", line 112, in __init__
> pyroom_config=pyroom_config)
>
> File "/home/swizec/pyroom/preferences.py", line 135, in __init__
> self.linespacing = self.config.get("visual", "linespacing")
>
> File "/usr/lib/python2.5/ConfigParser.py", line 520, in get
> raise NoOptionError(option, section)
>
> NoOptionError: No option 'linespacing' in section: 'visual'
>
>
> Please fix soon so I can go try if the new patch for two monitors works :P
>