Re: Application Preferences

2019-08-20 Thread Barry Scott



> On 19 Aug 2019, at 20:37, Dennis Lee Bieber  wrote:
> 
> On Mon, 19 Aug 2019 18:01:17 +, dboland9 via Python-list
>  declaimed the following:
> 
>> 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.
>> 
>   The trick with allowing a user to specify said location is that, unless
> you use some standard location to store the redirection, the user has to
> always provide the location when launching the application. And if you are
> using a standard location for the redirection, you might as well use that
> for the configuration data (since redirected user data location can be
> stored in the config file).

I understood your requirements. User picks the folder to store app files into.
The app then needs to store that folder somewhere.

I would ask the user for the their preferred location and store that folder in 
a OS standard location.

I do exactly that with Scm-Workbench. The user picks the folder to check out 
repos into
and I store that choice in the standard location.

Barry

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Application Preferences

2019-08-19 Thread dboland9 via Python-list
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  wrote:

>> On 19 Aug 2019, at 13:43, Dave via Python-list  
>> 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/ and data files
> in  ~/.local/share/. 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
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Application Preferences

2019-08-19 Thread Dave via Python-list

On 8/19/19 1:53 PM, Barry Scott wrote:




On 19 Aug 2019, at 13:43, Dave via Python-list  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/ and data files
in  ~/.local/share/. 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



Barry, and all,

I agree that various OS's have a favorite place to put things.  Python 
has a library that will help.  However, there are valid reasons to let 
the customer choose.  Perhaps the drive/folder is a journaling one, or 
one that is backed up multiple times per day.  My take is to start with 
the OS solution, but let the customer decide.


How did this thread show up in the SQLite mailing list anyway?  Really 
has nothing to do with SQLite that I can see.


Dave,


--
https://mail.python.org/mailman/listinfo/python-list


Re: Application Preferences

2019-08-19 Thread Barry Scott



> On 19 Aug 2019, at 13:43, Dave via Python-list  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/ and data files
in  ~/.local/share/. 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

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Application Preferences

2019-08-19 Thread Malcolm Greene
Hi Dave,

> I agree that a traditional INI file is the easiest way, especially since 
> Python supports them.  So if I understand you, your apps look like this:

Yes with the following nuance for our application sized scripts that require 
multiple configuration files. In this latter case, we place all config files in 
a ../conf folder (see the OR option below).

-App Dir
   |
   +-App Code Folder (src)
  |
  +-App INI file

OR

-App Dir
   |
   +-conf
  |
  +-App INI file

AND

-Home Folder (the default location, but user can select other locations)
   |
   +-App INI Folder
  |
  +-App INI file

Malcolm
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Application Preferences

2019-08-19 Thread Dave via Python-list

On 8/19/19 9:22 AM, Malcolm Greene wrote:

Hi Dave,


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?


We handle the "where is my config file" question by defaulting to script's 
current directory, then a script-specific folder within their home directory. Users can 
override that behavior by setting a script specific environment variable or by using a 
command line switch to point to a different location or config file.

We store our preferences in an INI style config file which we've found easier 
to support when there's problems.

Malcolm



Malcolm,

Thanks for the reply.  I agree that a traditional INI file is the 
easiest way, especially since Python supports them.  So if I understand 
you, your apps look like this:


-App Dir
  |
  +-App Code Folder
 |
 +-(File to direct to home folder)

-Home Folder (the default location, but user can select other locations)
  |
  +-App INI Folder
 |
 +-App INI file
--
https://mail.python.org/mailman/listinfo/python-list


Re: Application Preferences

2019-08-19 Thread Malcolm Greene
Hi Dave,

> 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?

We handle the "where is my config file" question by defaulting to script's 
current directory, then a script-specific folder within their home directory. 
Users can override that behavior by setting a script specific environment 
variable or by using a command line switch to point to a different location or 
config file.

We store our preferences in an INI style config file which we've found easier 
to support when there's problems.

Malcolm


-- 
https://mail.python.org/mailman/listinfo/python-list


Application Preferences

2019-08-19 Thread Dave via Python-list
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?


Thanks,
Dave
--
https://mail.python.org/mailman/listinfo/python-list