wx.lib.agw.persist

Hi,

I currently do something like this:

- setup controls
- do layout
- _persistMgr.RegisterAndRestoreAll

but I like to do:

- setup controls
- _persistMgr.RegisterAndRestoreAll
- if nothing restored:
   - do layout

But I can't figure out how to ask _persistMgr if there is something to be restored.

Looking at the doc.Usage section I see this code:
         if not PM.PersistenceManager.RegisterAndRestore(book):
             # Nothing was restored, so choose the default page ourselves
             book.SetSelection(0)

So, I thought I could patch RegisterAndRestoreAll but the call to RegisterAndRestore in there always returns True for me.

Appreciate any hints on this.

Werner

Hi Werner,

Hi,

I currently do something like this:

- setup controls
- do layout
- _persistMgr.RegisterAndRestoreAll

but I like to do:

- setup controls
- _persistMgr.RegisterAndRestoreAll
- if nothing restored:
  - do layout

But I can't figure out how to ask _persistMgr if there is something to be
restored.

Looking at the doc.Usage section I see this code:
        if not PM.PersistenceManager.RegisterAndRestore(book):
            # Nothing was restored, so choose the default page ourselves
            book.SetSelection(0)

So, I thought I could patch RegisterAndRestoreAll but the call to
RegisterAndRestore in there always returns True for me.

Appreciate any hints on this.

I think it's a bug in the Restore method in PersistentManager. Instead
of simply being:

self._persistentHandler.Restore()

It should be:

return self._persistentHandler.Restore()

Could you please check and see if it works this way?

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

···

On 1 December 2012 10:34, Werner wrote:

Hi Andrea,

Hi Werner,

...

I think it's a bug in the Restore method in PersistentManager. Instead
of simply being:

self._persistentHandler.Restore()

It should be:

return self._persistentHandler.Restore()

Could you please check and see if it works this way?

Thanks for the quick reply.

Attached a patch with the changes I made.

Not sure about the change in RegisterAndRestoreAll, it works but it doesn't look right/nice.

Werner

persist2.patch (1.33 KB)

···

On 01/12/2012 11:19, Andrea Gavana wrote:

Hi Werner,

Hi Andrea,

Hi Werner,

...

I think it's a bug in the Restore method in PersistentManager. Instead
of simply being:

self._persistentHandler.Restore()

It should be:

return self._persistentHandler.Restore()

Could you please check and see if it works this way?

Thanks for the quick reply.

Attached a patch with the changes I made.

Not sure about the change in RegisterAndRestoreAll, it works but it doesn't
look right/nice.

I have applied a slightly modified version of your patch, which now
sets an attribute (self._hasRestored) to True if anything was restored
by PersistenceManager. You can use the HasRestored() method of
PersistenceManager to check if anything was restored or not.

Could you please see if the patch does what you need?

Thank you!

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

···

On 1 December 2012 12:55, Werner wrote:

On 01/12/2012 11:19, Andrea Gavana wrote:

Hi Andrea,
...

I have applied a slightly modified version of your patch, which now
sets an attribute (self._hasRestored) to True if anything was restored
by PersistenceManager. You can use the HasRestored() method of
PersistenceManager to check if anything was restored or not.

Could you please see if the patch does what you need?

I like that approach better, but it didn't quit work out of the box:).

RegisterAndRestoreAll will also be called for "BAD_DEFAULT_NAMES", which meant that _hasRestored would get reset.

Werner

persist3.patch (1.15 KB)

···

On 03/12/2012 22:26, Andrea Gavana wrote:

Hi Werner,

Hi Andrea,
...

I have applied a slightly modified version of your patch, which now
sets an attribute (self._hasRestored) to True if anything was restored
by PersistenceManager. You can use the HasRestored() method of
PersistenceManager to check if anything was restored or not.

Could you please see if the patch does what you need?

I like that approach better, but it didn't quit work out of the box:).

RegisterAndRestoreAll will also be called for "BAD_DEFAULT_NAMES", which
meant that _hasRestored would get reset.

Thanks, I must be getting too old to keep up with this stuff :slight_smile:

I'll upload the new patch when I get home tonight.

Thank you!

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

···

On 4 December 2012 12:07, Werner wrote:

On 03/12/2012 22:26, Andrea Gavana wrote:

Hi Werner,

Hi Andrea,
...

I have applied a slightly modified version of your patch, which now
sets an attribute (self._hasRestored) to True if anything was restored
by PersistenceManager. You can use the HasRestored() method of
PersistenceManager to check if anything was restored or not.

Could you please see if the patch does what you need?

I like that approach better, but it didn't quit work out of the box:).

RegisterAndRestoreAll will also be called for "BAD_DEFAULT_NAMES", which
meant that _hasRestored would get reset.

Thanks, I must be getting too old to keep up with this stuff :slight_smile:

Or maybe trying to do too many things at the same time;-)

I'll upload the new patch when I get home tonight.

Thanks and btw thanks for the AquaButton one.

Werner

···

On 04/12/2012 12:13, Andrea Gavana wrote:

On 4 December 2012 12:07, Werner wrote:

On 03/12/2012 22:26, Andrea Gavana wrote:

Hi Andrea,

It looks like this has not yet made it into SVN

Werner

persist3.patch (1.15 KB)

···

:wink:

  -------- Original Message --------

Subject:
Re: [wxPython-users] wx.lib.agw.persist
Date:
Tue, 04 Dec 2012 12:07:06 +0100
From:
Werner
Reply-To:
To:
werner.bruhin@sfr.frwxpython-users@googlegroups.comwxpython-users@googlegroups.com


Hi Andrea,
On 03/12/2012 22:26, Andrea Gavana wrote:
...
> I have applied a slightly modified version of your patch, which now
> sets an attribute (self._hasRestored) to True if anything was restored
> by PersistenceManager. You can use the HasRestored() method of
> PersistenceManager to check if anything was restored or not.
>
> Could you please see if the patch does what you need?
I like that approach better, but it didn't quit work out of the box:).
RegisterAndRestoreAll will also be called for "BAD_DEFAULT_NAMES", which meant that _hasRestored would get reset.
Werner
-- To unsubscribe, send email to or visit

wxPython-users+unsubscribe@googlegroups.comhttp://groups.google.com/group/wxPython-users?hl=en

Hi Werner,

Hi Andrea,

It looks like this has not yet made it into SVN ;-)

I have applied it, about two weeks ago:

http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/AGW/agw/persist/persistencemanager.py?r1=73118&r2=73129&sortby=date

Both in wxPython Classic and Phoenix. Am I missing something? IT’s slightly different from your patch, but simply because this code:

topRetVal = self.RegisterAndRestore(window)

if topRetVal:

self._hasRestored = True

else:

self._hasRestored = False

Can be re-written as:

self._hasRestored = self.RegisterAndRestore(window)

···

On 17 December 2012 15:00, Werner wrote:

Werner




  -------- Original Message --------

Subject:
Re: [wxPython-users] wx.lib.agw.persist
Date:
Tue, 04 Dec 2012 12:07:06 +0100
From:
Werner werner.bruhin@sfr.fr
Reply-To:
wxpython-users@googlegroups.com
To:
wxpython-users@googlegroups.com


Hi Andrea,
On 03/12/2012 22:26, Andrea Gavana wrote:
...
> I have applied a slightly modified version of your patch, which now
> sets an attribute (self._hasRestored) to True if anything was restored
> by PersistenceManager. You can use the HasRestored() method of
> PersistenceManager to check if anything was restored or not.
>
> Could you please see if the patch does what you need?
I like that approach better, but it didn't quit work out of the box:).
RegisterAndRestoreAll will also be called for "BAD_DEFAULT_NAMES", which meant that _hasRestored would get reset.
Werner
-- To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit [http://groups.google.com/group/wxPython-users?hl=en](http://groups.google.com/group/wxPython-users?hl=en)

To unsubscribe, send email to wxPython-dev+unsubscribe@googlegroups.com

or visit http://groups.google.com/group/wxPython-dev?hl=en


Andrea.

“Imagination Is The Only Weapon In The War Against Reality.”
http://www.infinity77.net

-------------------------------------------------------------

def ask_mailing_list_support(email):

if mention_platform_and_version() and include_sample_app():
    send_message(email)
else:
    install_malware()
    erase_hard_drives()

-------------------------------------------------------------

Sorry didn’t notice that, so you only partially applied it:)
The difference is the following line at the beginning of the method:
self._hasRestored = False
Werner

···

On 17/12/2012 15:02, Andrea Gavana
wrote:

Hi Werner,

On 17 December 2012 15:00, Werner wrote:

Hi Andrea,

        It looks like this has not yet made it into SVN
            ;-)

I have applied it, about two weeks ago:

http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/AGW/agw/persist/persistencemanager.py?r1=73118&r2=73129&sortby=date

      Both in wxPython Classic and Phoenix. Am I missing

something? IT’s slightly different from your patch, but simply
because this code:

        topRetVal =

self.RegisterAndRestore(window)

if topRetVal:

self._hasRestored = True

else:

self._hasRestored = False

Can be re-written as:

self._hasRestored = self.RegisterAndRestore(window)

Done, it should be OK now but please let me know if I still
misunderstood something...

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."

# ------------------------------------------------------------- #
def ask_mailing_list_support(email):

    if mention_platform_and_version() and include_sample_app():
        send_message(email)
    else:
        install_malware()
        erase_hard_drives()
# ------------------------------------------------------------- #

···

On 17 December 2012 16:52, Werner wrote:

On 17/12/2012 15:02, Andrea Gavana wrote:

Hi Werner,

On 17 December 2012 15:00, Werner wrote:

Hi Andrea,

It looks like this has not yet made it into SVN :wink:

I have applied it, about two weeks ago:

http://svn.wxwidgets.org/viewvc/wx/wxPython/3rdParty/AGW/agw/persist/persistencemanager.py?r1=73118&r2=73129&sortby=date

Both in wxPython Classic and Phoenix. Am I missing something? IT's slightly
different from your patch, but simply because this code:

                 topRetVal = self.RegisterAndRestore(window)
                 if topRetVal:
                     self._hasRestored = True
                else:
                    self._hasRestored = False

Can be re-written as:

self._hasRestored = self.RegisterAndRestore(window)

Sorry didn't notice that, so you only partially applied it:)

The difference is the following line at the beginning of the method:

        self._hasRestored = False

Hi Andrea,

..

Done, it should be OK now but please let me know if I still
misunderstood something...

Thanks, works as advertised:)

Have a nice evening
Werner

···

On 17/12/2012 21:17, Andrea Gavana wrote: