1

GIO (GLib's I/O library) has a backend for GSettings that uses a keyfile. From C, you can create an instance of this backend in order to force use of a keyfile instead of the system registry, using g_keyfile_settings_backend_new() and then g_settings_new_with_backend(). However, to do this, you must #define G_SETTINGS_ENABLE_BACKEND in your code, since the backend public API is unstable.

I would like to do this from Python, using PyGObject (just to be clear, since this term is confusing - this is the GObject introspection library that goes with GTK 3, not the PyGObject that goes with PyGTK and GTK 2.) I can do

>>> from gi.repository import Gio
>>> 'SettingsBackend' in dir(Gio)
True

However, there's no function corresponding to g_keyfile_settings_backend_new() in dir(Gio). If I try instantiating a backend,

>>> Gio.SettingsBackend()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
MemoryError

So, does anybody have any pointers? Or maybe the Python module wasn't compiled with G_SETTINGS_ENABLE_BACKEND and I'm out of luck?

ptomato
  • 56,175
  • 13
  • 112
  • 165
  • I have no idea if this is related, but I had a similar issue when trying to use GLib.KeyFile and it turned out to be a bug that someone fixed in the version Ubuntu 12.04 uses. I have yet to track down the place where the fix was made. You may want to try a VM with a newer copy of the OS, if possible, or check gnome's bug tracker. – mfisch Feb 02 '12 at 21:16
  • I can confirm that this problem isn't fixed in Ubuntu 12.04. – ptomato May 24 '12 at 12:55
  • I can get it to work by recompiling gobject-introspection. I submitted a bug on bugzilla.gnome.org: [link](https://bugzilla.gnome.org/show_bug.cgi?id=682702) – ptomato Aug 25 '12 at 22:54

0 Answers0