Problem with wx.onfig.Exists

Hello all,

There is something I dont understand with the behaviour of wx.Config.Exists

I am using Python 2.3.4, wxPython 2.5.3.1 on windows 2000
and I have reduced my problem to this simple test. (at the end of message)

Here is the behaviour.

If testwxconfig is not yet in the registry,
pressing "Get" will return:
Exists / ? True
Exists /testing ? False
which is ok

Press now Set: this will set the value in registry (that can be checked with regedit).

Press Get:
result is:
Exists / ? False
Exists /testing ? False
42

so value can be read even if
self.__cfg.Exists('/Testing') returns False

Press Get one more time:
Exists / ? True
Exists /testing ? True

If testwxconfig is in the registry, first call to Get still return
self.__cfg.Exists('/Testing') : False.

So, is there something I dont understand withConfig.Exists or is this a bug,
do you see some workardound for that in that case ?

Thanks for your help.

   Stéphane Ninin

# -*- coding: iso-8859-15 -*-

import sys
import wx

class TestWindow(wx.Frame):
       def __init__(self,parent):

        self.__cfg = wx.Config('testwxconfig')
               wx.Frame.__init__(self,parent,-1,"Test window", style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
               self.Setup()
        self.RegisterEvents()

    def Setup(self):
        self.buttonGet = wx.Button(self,-1,"Get")
        self.buttonSet = wx.Button(self,-1,"Set")
        self.buttonCancel = wx.Button(self,wx.ID_CANCEL,"Cancel")
               sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.buttonCancel,0,wx.ALIGN_CENTER)
        sizer.Add(self.buttonSet,0,wx.ALIGN_CENTER)
        sizer.Add(self.buttonGet,0,wx.ALIGN_CENTER)

        self.SetSizer(sizer)
        self.SetAutoLayout(1)
        sizer.Fit(self)

    def RegisterEvents(self):
        self.Bind(wx.EVT_BUTTON,self.OnClose,id=self.buttonCancel.GetId())
        self.Bind(wx.EVT_BUTTON,self.OnGet,id=self.buttonGet.GetId())
        self.Bind(wx.EVT_BUTTON,self.OnSet,id=self.buttonSet.GetId())
           def OnClose(self,evt):
        self.Destroy()

       def OnSet(self,evt):
        self.__cfg.SetPath('/Testing')
        self.__cfg.Write('val1','42')
        self.__cfg.SetPath('/')
        self.__cfg.Flush()

    def OnGet(self,evt):
        self.__cfg.Flush()

        print "Exists / ?", self.__cfg.Exists('/')
        print
               print 'Exists /testing ?', self.__cfg.Exists('/Testing')
        print
       
               value = self.__cfg.Read('val1')
        print value
               
def main():
    app = wx.PySimpleApp()
    w = TestWindow(None)
    w.Show()
    app.MainLoop()

main()