[Python-Dev] 'userprefs.py': Looking for help for WinXX (was Re: user dirs on Non-Unix platforms...)

Peter Funk pf@artcom-gmbh.de
Wed, 31 May 2000 09:34:34 +0200 (MEST)


> Gordon writes,
> 
> > But there's no $HOME as such.
> >
> > There's
> > HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\S
> > hell Folders with around 16 subkeys, including AppData
> > (which on my system has one entry installed by a program I've
> > never used and didn't know I had). But MSOffice uses the
> > Personal subkey. Others seem to use the Desktop subkey.

Neil responds:
>    SHGetSpecialFolderPath(,,CSIDL_APPDATA,) would be the current 'MS
> preferred' method for this as it allows roaming (not that I've ever seen
> roaming work). If Unix code expects $HOME to be per machine (and so used to
> store, for example, window locations which are dependent on screen
> resolution) then CSIDL_LOCAL_APPDATA would be a better choice.
> 
>    To make these work on 9x and NT 4 Microsoft provides a redistributable
> Shfolder.dll.

Using a place on the local machine of the user makes more sense to me.

But excuse my ingorance: I've just 'grep'ed through the Python 1.6a2
sources and also through Mark Hammonds Win32 Python extension c++
sources (here on my Notebook running Linux) and found nothing called
'SHGetSpecialFolderPath'.  So I believe, this API is currently not
exposed to the Python level.  Right?

So it would be very nice, if you WinXX-gurus more familar with the WinXX
platform would come up with some Python code snippet, which I could try
to include into an upcoming standard library 'userprefs.py' I plan to
write.  something like:
    if os.name == 'nt':
        try:
            import win32XYZ
            if hasattr(win32XYZ, 'SHGetSpecialFolderPath'):
                userplace = win32XYZ.SHGetSpecialFolderPath(.....) 
        except ImportError:
            .....
would be very fine.

>    Fred writes,
> 
> >  Look at your $HOME on Unix box; most of the dotfiles are *files*, not
> > directories, and that's all most applications need;
> 
>    This may have been the case in the past and for people who understand
> Unix well enough to maintain it, but for us just-want-it-to-run folks, its
> no longer true. I formatted my Linux partition this week and installed Red
> Hat 6.2 and Gnome 1.2 and then used a few applications. The dot directories
> outnumber the dot files 18 to 16.

Fred proposed an API, which leaves the decision whether to use a
single file or to use several files in special directory up to the
application developer.  

I aggree with Fred.  

Simple applications will use only a simple config file, where bigger
applications will need a directory to store several files.

Regards, Peter
-- 
Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260
office: +49 421 20419-0 (ArtCom GmbH, Grazer Str.8, D-28359 Bremen)