Yes, that’s essentially what I posted above too, however I’m trying to find programatically what the result of this internal check/creation is.
On a Linux system, for example, you can’t tell via isinstance that it chose wx.FileConfig, because the wx.Config object doesn’t transform:
snowleopard% python2
Python 2.7.11 (default, Dec 6 2015, 15:43:46)
[GCC 5.2.0] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
import wx
app = wx.App(False)
config = wx.Config(“MyApp”)
isinstance(config, wx.FileConfig)
False
Unfortunately I start to get lost while trying to read the code to figure it out.
https://github.com/wxWidgets/wxPython/blob/14476d72d92c44624d5754c4f1fac2e8d7bc30da/src/gtk/_misc.py#L3486 is where the class Config is defined with the constructor ultimately calling misc.Config_swiginit(self,misc.new_Config(*args, **kwargs)), however misc is not python, but the CPP swig object.
Further to this, it looks like (as you’d expect of the complied portion) the decision is not ‘made’ during runtime, but at compile. (there’s both a gtk/_misc_wrap.cpp and msw/_misc_wrap.cpp that contain the code for new_Config). However so far reading through the C++ code, I’ve been unable to identify something that “flags” the underlying mechanism wx.Config is using.
Sounds like this is a lot more complicated than I thought it would be.
If this actually can’t be accomplished (which is starting to look like the case) a hacky way I could accomplish this would be (this is untested… I’ll try it out tomorrow when I get some more time) and assumes I’ll get control back from MainLoop():
import wx
import os.path
…
app = wx.App(False)
config = wx.Config(“MyApp”)
…
app.MainLoop()
filename = wx.FileConfig(“MyApp”).GetLocalFileName(“MyApp”)
if os.path.isfile(filename):
# Do the local filesystem specific stuff here
Any thoughts or opinions on that approach?
···
On Sunday, February 14, 2016 at 5:05:09 PM UTC-8, austin aigbe wrote:
Take a look at the source code: https://github.com/wxWidgets/wxPython/blob/14476d72d92c44624d5754c4f1fac2e8d7bc30da/src/gtk/_misc.py
On Linux, wx.Config will use wx.FileConfig. I can’t even find RegConfig in the source code, I guess RegConfig is the same a the Windows registry.
class Config(ConfigBase):
“”"
This ConfigBase-derived class will use the registry on Windows,
and will be a wx.FileConfig on other platforms.
“”"
class FileConfig(ConfigBase):
“”“This config class will use a file for storage on all platforms.”“”
Then the base class:
class ConfigBase(object):
“”"
wx.ConfigBase class defines the basic interface of all config
classes. It can not be used by itself (it is an abstract base class)
and you will always use one of its derivations: wx.Config or
wx.FileConfig.
wx.ConfigBase organizes the items in a tree-like structure, modeled
after the Unix/Dos filesystem. There are groups that act like
directories and entries, key/value pairs that act like files. There
is always one current group given by the current path. As in the file
system case, to specify a key in the config class you must use a path
to it. Config classes also support the notion of the current group,
which makes it possible to use relative paths.
Keys are pairs “key_name = value” where value may be of string,
integer floating point or boolean, you can not store binary data
without first encoding it as a string. For performance reasons items
should be kept small, no more than a couple kilobytes.
“”"Regards,
Austin
On Saturday, February 13, 2016 at 2:38:10 AM UTC+1, Jason Ahrens wrote:
Correct, this is regarding wx.Config module: http://wxpython.org/Phoenix/docs/html/ConfigBase.html (and associated wx.FileConfig)
The problem I’m having is: wx.Config ends up being a layer over the actual config type. On Windows it’s a “wx.RegConfig” (which I’ve been unable to find any direct documentation for) and on other platforms it’s a wx.FileConfig. However type(configObj) just returns it’s type ‘wx._misc.Config’ so I can’t actually tell what its behaviour is going to be. None of the wx.FileConfig specific methods are exposed.
I need to detect if wx.Config is using wx.FileConfig as the underlying config module or not so I can do necessary file system work appropriately given the different data storage medium.
On Thursday, February 11, 2016 at 3:34:12 AM UTC-8, James Scholes wrote:
Nathan McCorkle wrote:
This doesn’t sound like a wxPython question, rather a question for the
config module usage
The Config module which is a part of wxPython, that is.
–
James Scholes
http://twitter.com/JamesScholes