Per user dirs on Non-Unix platforms (was Re: [Python-Dev] Where to install non-code files)

Fred L. Drake, Jr.
Tue, 30 May 2000 10:17:56 -0700 (PDT)

Peter Funk writes:
 >     Imagine you are using grail version 4.61 on a daily basis for WWW 
 >     browsing and one day you decide to install the nifty upgrade 
 >     grail 4.73 on your computer running WinXX or MacOS X.Y 

  God thing you marked that as fantasy -- I would have asked for the
download URL!  ;)

 > Do people remember 'grail'?  I've just stolen the following code snippets

  Not on good days.  ;)

 > I'm not sure whether this is really generic enough for the OS module.

  The location selected is constrained by the OS, but this isn't an
exposure of operating system functionality, so there should probably
be something else.

 > May be we should introduce a new small standard library module called 
 > 'userprefs' or some such?  A programmer with a MacOS or WinXX  background 
 > will probably not know what to do with 'os.gethomedir()'.  
 > However for the time being this module would only contain one simple 
 > function returning a directory pathname, which is guaranteed to exist 
 > and to survive a deinstallation of an application.  May be introducing

  Look at your $HOME on Unix box; most of the dotfiles are *files*, not
directories, and that's all most applications need; Web browser are a
special case in this way; there aren't that many things that require a
directory.  Those things which do often are program that form an
essential part of a user's environment -- Web browsers and email
clients are two good examples I've seen that really seem to have a lot
of things.
  I think what's needed is a function to return the location where the
application can make one directory entry.  The caller is still
responsible for creating a directory to store a larger set of files if
needed.  Something like grailbase.utils.establish_dir() might be a
nice convenience function.
  An additional convenience may be to offer a function which takes the
application name and a dotfile name, and returns the one to use; the
Windows and MacOS (and BeOS?) worlds seem more comfortable with the
longer, mixed-case, more readable names, while the Unix world enjoys
cryptic little names with a dot at the front.
  Ok, so now that I've rambled, the "userprefs" module looks like it

        get_appdata_root() -- $HOME, or other based on platform
        get_appdata_name() -- "MyApplication Preferences" or ".myapp"
        establish_dir() -- create dir if it doesn't exist

  Maybe this really is a separate module.  ;)


Fred L. Drake, Jr.  <fdrake at>