wx.ConfigBase issue - DeleteEntry() won't work without a Write()

I'm still fairly new to wx.Config, and really new to python, and I've
run into a problem that has been causing me frustration for a while.
It's quite possible, that my understanding of wx.Config is the problem,
but I can't find a lot of good examples out there of people dealing with
it.

I've tried to reduce this problem I'm having to the smallest case I can
reproduce it. (see below) In this example, self is an instance of the
wx.Config class.

If I comment out the Write, the delete will never show up in the
~/.python wx.config file. I've been doinking with this for quite a
while, and I've tested lots of different sets of data from my .python
file.

Another interesting twist is that if I have only one entry in the group
and delete that, it works as expected and writes the changes out fine as
should be expected.

Any clues?

This is just a simple loop that searches through the current wx.config
(self in this case) and deletes it if "item" is equal to the value of
the config entry.
    
        i=1

        # entry_info is a tuple (more,value,index)
        # NOTE: value actually returns the "key" of the config entry
        # I'm keeping this label so it's the same as the docs
        entry_info = self.GetFirstEntry()

        while entry_info[0]:

            VALUE = self.Read(str(entry_info[1]), "EMTPY")

            #If the entry is found, then do the delete.
            if VALUE == item:
                try:
                    deleted = self.DeleteEntry(str(entry_info[1]),deleteGroupIfEmpty=True)

                    # !!! HERE IS THE PROBLEM !!!
                    # If I comment this out, it doesn't get written out to the
                    # actual wx.config object
                    write = self.Write(str(entry_info[1]),"somestring")

                    flushed = self.Flush(False)
                except:
                    return 0
                break

            i = i + 1
            entry_info = self.GetNextEntry(entry_info[2])

pete@mu.org wrote:

If I comment out the Write, the delete will never show up in the
~/.python wx.config file. I've been doinking with this for quite a
while, and I've tested lots of different sets of data from my .python
file.

It's a bug. The DeleteEntry wasn't setting the "dirty" flag unless it deleted the group so the flush didn't do anything unless something else set the flag. I've checked in a fix.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Excellent, thanks!

···

On Sat, Jun 04, 2005 at 10:47:06AM -0700, Robin Dunn wrote:

pete@mu.org wrote:

>If I comment out the Write, the delete will never show up in the
>~/.python wx.config file. I've been doinking with this for quite a
>while, and I've tested lots of different sets of data from my .python
>file.

It's a bug. The DeleteEntry wasn't setting the "dirty" flag unless it
deleted the group so the flush didn't do anything unless something else
set the flag. I've checked in a fix.

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org