Application Preferences

dboland9 dboland9 at protonmail.com
Mon Aug 19 14:01:17 EDT 2019


Wow, what happened here?  I posted this to the Python discussion group as it is a Python question, not an SQL question.  That said, I agree with what you have said, and that was the plan.  Plans get changed.  A number of apps. allow the user to specify the location of data and configuration files, and for good reason.  Some folders are auto-backup in that they are either journaled or backed up multiple times per day.  I think that is the argument in this case.

Dave,

Sent with [ProtonMail](https://protonmail.com) Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, August 19, 2019 1:53 PM, Barry Scott <barry at barrys-emacs.org> wrote:

>> On 19 Aug 2019, at 13:43, Dave via Python-list <python-list at python.org> wrote:
>>
>> The plan for an app that I'm doing was to use SQLite for data and to hold the preference settings as some apps do.  The plan was changed last week to allow the user to select the location of the data files (SQLite) rather than putting it where the OS would dictate.  Ok with that, but it brings up some questions.  First, I will need to have a file that points to the location of the data file  since that can't be hard coded. Second, if I have to have a file that is likely part of the application group of files, would it make more sense to use a more traditional preferences file?  How have other Python app developers done in this case?
>
> There are expected locations for config files and data files on each OS.
>
> On macOS you would use ~/Library/Preferences/ and put a file or a folder of files in there.
> The convention is use your website name as the base name of the  file or folder.
> For example for scm-workbench I use: org.barrys-emacs.scm-workbench as the folder name for
> all the scm-workbench files.
>
> On Windows you can use a file or folder in %APPDATA% that is named after your app. You should
> find the folder by doing a win32 API call to get the value. See getPreferencesDir()  in
> https://github.com/barry-scott/scm-workbench/blob/master/Source/Common/wb_platform_win32_specific.py
> for how to get the value.
>
> On Linux the XDG spec says that you should put config files in ~/.config/<app-name> and data files
> in  ~/.local/share/<app-name>. Doing XDG to the spec is a little involved. I have some experimental
> code that implements the logic for config the XdgConfigPath class in:
> https://github.com/barry-scott/CLI-tools/blob/master/Source/smart_find/__init__.py
>
> Putting a file directly in the $HOME folder is no longer recommended.
>
> The format of the config data you are free to choose.
> I have been using JSON files recently as it allow for structured data.
>
> Barry


More information about the Python-list mailing list