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

Bob Savage savageb@pacbell.net
Mon, 29 May 2000 13:12:47 -0700


Peter Funk wrote:
> So let me ask: If differently: *HOW* should this things be done on the Mac?

John Baxter wrote:
> One way would be to use Mac OS 9's multi-user feature (IF it is stable on
> one's Macs, as it is not on my 8100).  Each different user login has its
> own Preferences folder, own Documents folder, etc.  The OS call which
> returns references to those folders and many others--which has been around
> since 1991--returns the folders related to the current user when Mac OS 9
> multi user is in use.  That is the FindFolder() function in the C/C++
> APIs...I haven't examined that part of Mac Python to see how it is called
> in Python.

James Durchenwald wrote:
> You should go ahead and change the "global" preference.

Jack Jansen wrote:
> MacOS X turns the world inside out

I think we are all saying the same things largely, but I thought it could be
organized differently.

Pre-MacOS 9
    get preferences via FindFolder()
    [caveat: global preferences change]

MacOS 9 without Multi-User turned on
    get preferences via FindFolder()
    [caveat: global preferences change]

MacOS 9 *with* Multi-User
    get preferences via FindFolder()
    [caveat: MU was hacked onto a single-user system so it can introduce
some instability. I have noticed this myself, and would say that it "sort
of" works.]

MacOS X
    get preferences via FindFolder()
    os.environ['HOME'] ??
    [caveat: insert moving target warning here (see below)]


Some specifics:

* macfs.FindFolder

"FindFolder (where, which, create)
Locates one of the ``special'' folders that MacOS knows about, such as the
trash or the Preferences folder. where is the disk to search, which is the
4-character string specifying which folder to locate. Setting create causes
the folder to be created if it does not exist. Returns a (vrefnum, dirid)
tuple." -- look in the docs for more.

The multiple users feature of MacOS 9 will ensure that you receive the
correct one. As James Durchenwald pointed out, this is done through some
sleight of hand. The folders are swapped in and out by the system so that
older apps will get what they expect.

* MacOS X

Still in development and represents a major change to the "MacOS
Philosophy". Documentation is just appearing, but I think it is fair to say
that changes are to be expected up through July at least. As to FindFolder,
this method is "Carbon Compliant" (meaning that it will be there in MacOS X)
but I think that there will be some work needed when X ships; The standard
behavior under X seems to be to put preferences in ~/Library/[appname]
instead of the current standard of putting everything in the "Preferences"
folder -- will a request via FindFolder return the user's Library directory?
or perhaps the ~/Library/Carbon directory? I don't know.

Regarding "os.environ['HOME']": Apple is putting out a new version of
"Inside Macintosh". A "Preliminary" version of "Inside Mac OS X: System
Overview" was released a couple of weeks ago:
 <http://developer.apple.com/techpubs/macosx/macosx.html>. I quote:

"In developer versions of Mac OS X, the kernal environment exports BSD
services and commands to the upper layers of the system through the System
framework. User versions of Mac OS X do not."

Does this mean that there will be an API for accessing BSD environment
variables or not? I don't know.

Best of luck with your project,

Bob Savage