Re: [Zim-wiki] Win32: configuration path
On Mon, Oct 29, 2012 at 9:52 AM, klo uo klo...@gmail.com wrote: Now I have a suggestion: If you are willing to change this behavior for Windows users and their special folders (http://en.wikipedia.org/wiki/Special_folder), please don't use just %USERPROFILE% aka os.path.expanduser('~'), as that's *nix setting. Appropriate folder for storing application related data is set in env variable %APPDATA%. Location for local application data which could pair XDG_DATA_HOME, is not set in env variable in Windows XP, but it is in Windows 7. Maybe you can just set XDG_DATA_HOME to %APPDATA%\zim or use some instrument to reveal it for both XP/7/... This sounds like a reasonable proposal. Indeed setting XDG_DATA to the relevant path will change the lookup path for zim. Probably you'll also want to do something similar for XDG_CONFIG and XDG_CACHE. All these parameters are initialized in zim/config.py, feel free to patch it accordingly and submit the patch through a bug report. Regards, Jaap P.S. behavior is documented in the manual, so you could have saved a bit of trouble by looking there instead of going over the code ;) ___ Mailing list: https://launchpad.net/~zim-wiki Post to : zim-wiki@lists.launchpad.net Unsubscribe : https://launchpad.net/~zim-wiki More help : https://help.launchpad.net/ListHelp
Re: [Zim-wiki] Win32: configuration path
Hi Japp, This sounds like a reasonable proposal. Indeed setting XDG_DATA to the relevant path will change the lookup path for zim. Probably you'll also want to do something similar for XDG_CONFIG and XDG_CACHE. All these parameters are initialized in zim/config.py, feel free to patch it accordingly and submit the patch through a bug report. I did this (diff -b): 99a100,103 if not 'APPDATA' in os.environ or not os.environ['APPDATA']: os.environ['APPDATA'] = os.environ['HOME'] 140a145,160 if os.name == 'nt': XDG_DATA_HOME = Dir( get_environ('XDG_DATA_HOME', os.environ['APPDATA'] + '//zim//data')) XDG_DATA_DIRS = Dir( get_environ('XDG_DATA_DIRS', os.environ['APPDATA'] + '//zim//data//zim')) XDG_CONFIG_HOME = Dir( get_environ('XDG_CONFIG_HOME', os.environ['APPDATA'] + '//zim//config')) XDG_CONFIG_DIRS = Dir( get_environ('XDG_CONFIG_DIRS', os.environ['APPDATA'] + '//zim//config//zim')) XDG_CACHE_HOME = Dir( get_environ('XDG_CACHE_HOME', os.environ['APPDATA'] + '//zim//cache')) else: Local settings folders can be retrieved from registry, but that's probably not so good idea This proposed folder structure doesn't look very good, as Zim code is made in respect to XDG suggestions and rest of the code will need changes to make more proper Windows special folders pairing. But that's not some big problem, and this way Zim config files will be in one place where it's expected on Windows - %APPDATA% folder. I tested these settings, but I'm just not sure about XDG_xxx_DIRS variables and their role P.S. behavior is documented in the manual, so you could have saved a bit of trouble by looking there instead of going over the code ;) Thanks. Good to know that manual includes technical details, which I didn't expect ;) Cheers ___ Mailing list: https://launchpad.net/~zim-wiki Post to : zim-wiki@lists.launchpad.net Unsubscribe : https://launchpad.net/~zim-wiki More help : https://help.launchpad.net/ListHelp
Re: [Zim-wiki] Win32: configuration path
On Mon, Oct 29, 2012 at 3:36 PM, klo uo klo...@gmail.com wrote: XDG_DATA_HOME = Dir( get_environ('XDG_DATA_HOME', os.environ['APPDATA'] + '//zim//data')) XDG_DATA_DIRS = Dir( get_environ('XDG_DATA_DIRS', os.environ['APPDATA'] + '//zim//data//zim')) XDG_CONFIG_HOME = Dir( get_environ('XDG_CONFIG_HOME', os.environ['APPDATA'] + '//zim//config')) XDG_CONFIG_DIRS = Dir( get_environ('XDG_CONFIG_DIRS', os.environ['APPDATA'] + '//zim//config//zim')) XDG_CACHE_HOME = Dir( get_environ('XDG_CACHE_HOME', os.environ['APPDATA'] + '//zim//cache')) I tested these settings, but I'm just not sure about XDG_xxx_DIRS variables and their role The XDG_xxx_DIRS variables are lookup paths for system defaults for files not found in the corresponding XDG_xxx_HOME folder. So should probably include at least the fallback location. Probably the CACHE variable should go to a folder for temporary data. Not %TMP% because we want it available longer, but it can be flushed when space is needed on the system. Regards, Jaap ___ Mailing list: https://launchpad.net/~zim-wiki Post to : zim-wiki@lists.launchpad.net Unsubscribe : https://launchpad.net/~zim-wiki More help : https://help.launchpad.net/ListHelp
Re: [Zim-wiki] Win32: configuration path
On Mon, Oct 29, 2012 at 3:43 PM, Jaap Karssenberg wrote: The XDG_xxx_DIRS variables are lookup paths for system defaults for files not found in the corresponding XDG_xxx_HOME folder. So should probably include at least the fallback location. If I read this right, then if XDG_xxx_DIRS are set to *nix XDG_xxx_HOME values, they can serve as compatibility layer for user already having data from previous version: XDG_DATA_DIRS = Dir( get_environ('XDG_DATA_HOME', '~/.local/share/')) XDG_CONFIG_DIRS = Dir( get_environ('XDG_CONFIG_HOME', '~/.config/')) So that if user has config files as in zim 0.57 config folders, above snippet will make it compatible to potentially new config folder scheme? Probably the CACHE variable should go to a folder for temporary data. Not %TMP% because we want it available longer, but it can be flushed when space is needed on the system. I don't know about existence of other temporary folder except %TMP% and %TEMP% ___ Mailing list: https://launchpad.net/~zim-wiki Post to : zim-wiki@lists.launchpad.net Unsubscribe : https://launchpad.net/~zim-wiki More help : https://help.launchpad.net/ListHelp
Re: [Zim-wiki] Win32: configuration path
On Mon, Oct 29, 2012 at 8:42 PM, Jaap Karssenberg wrote: So that if user has config files as in zim 0.57 config folders, above snippet will make it compatible to potentially new config folder scheme? Yes, that is the idea. That sounds great :) Probably the CACHE variable should go to a folder for temporary data. Not %TMP% because we want it available longer, but it can be flushed when space is needed on the system. I don't know about existence of other temporary folder except %TMP% and %TEMP% Isn't there a folder that is also used for things like temporary internet files ? Sure, and by just looking in there I see Gimp also uses it for caching (gegl) With SPL folder can be located by reading the registry (on any Windows version): import _winreg as wreg wreg_key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, r'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders') wreg.QueryValueEx(wreg_key, Cache) (u'%USERPROFILE%\\Local Settings\\Temporary Internet Files', 2) And: import os wreg.QueryValueEx(wreg_key, Cache)[0].replace(u'%USERPROFILE%', os.environ['USERPROFILE']) u'C:\\Documents and Settings\\klo\\Local Settings\\Temporary Internet Files' wreg.CloseKey(wreg_key) So, considering previous talk, something like this should be sensible for Windows users: if os.name == 'nt': import _winreg as wreg XDG_DATA_HOME = Dir( get_environ('XDG_DATA_HOME', os.environ['APPDATA'] + '//zim//data')) XDG_DATA_DIRS = Dir( get_environ('XDG_DATA_HOME', '~/.local/share/')) XDG_CONFIG_HOME = Dir( get_environ('XDG_CONFIG_HOME', os.environ['APPDATA'] + '//zim//config')) XDG_CONFIG_DIRS = Dir( get_environ('XDG_CONFIG_HOME', '~/.config/')) try: wreg_key = wreg.OpenKey(wreg.HKEY_CURRENT_USER, r'Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders') cache_dir = str(wreg.QueryValueEx(wreg_key, Cache)[0].replace(u'%USERPROFILE%', os.environ['USERPROFILE'])) wreg.CloseKey(wreg_key) except: cache_dir = os.environ['TEMP'] XDG_CACHE_HOME = Dir( get_environ('XDG_CACHE_HOME', cache_dir + '//zim')) ___ Mailing list: https://launchpad.net/~zim-wiki Post to : zim-wiki@lists.launchpad.net Unsubscribe : https://launchpad.net/~zim-wiki More help : https://help.launchpad.net/ListHelp
Re: [Zim-wiki] Win32: configuration path
On Tue, Oct 30, 2012 at 6:24 AM, klo uo wrote: ... XDG_DATA_HOME = Dir( get_environ('XDG_DATA_HOME', os.environ['APPDATA'] + '//zim//data')) ... Yet more issues, double forward slashes should be double backward slashes, or else Sorry, I just woke up :) Here is revisited snippet: http://pastebin.com/raw.php?i=jVBKRzLZ ___ Mailing list: https://launchpad.net/~zim-wiki Post to : zim-wiki@lists.launchpad.net Unsubscribe : https://launchpad.net/~zim-wiki More help : https://help.launchpad.net/ListHelp