wx.lib.pubsub in wxPython 2.8.11.0 and py2exe

I recall some issue on this but can't find but the final solution is for this.

I had in my module mypublisher.py:

from wx.lib.pubsub import Publisher
# variables instead of strings for topics
statusText = 1 # pass status text in data section
dataNeedsSaving = 2 # pass parent's name in data section to limit propagation, e.g. self.parent.Name
etc etc

def SetDefaults():
     global publisher
     publisher = Publisher()

SetDefaults()

I change it to:

import wx.lib.pubsub.setupv1
from wx.lib.pubsub import pub

#variable stuff

def SetDefaults():
     global publisher
## publisher = Publisher()
     publisher = pub.Publisher()

SetDefaults()

This works when I run it in e.g. Boa, but after I generate it with py2exe I get the following exception:
**** Fri Aug 06 11:25:28 2010 **** Version: 3.1.747.9 **** wxV: 2.8.11.0 (msw-unicode) *****
Traceback (most recent call last):
   File "twcb.py", line 1497, in <module>
   File "twcb.py", line 1493, in main
   File "wx\_core.pyo", line 7978, in __init__
   File "wx\_core.pyo", line 7552, in _BootstrapApp
   File "twcb.py", line 341, in OnInit
   File "twcbF.pyo", line 41, in create
   File "twcbF.pyo", line 230, in __init__
   File "wx\lib\pubsub\core\publisherbase.pyo", line 141, in subscribe
   File "wx\lib\pubsub\core\topicmgr.pyo", line 173, in getOrCreateTopic
   File "wx\lib\pubsub\core\topicmgr.pyo", line 107, in getTopic
   File "wx\lib\pubsub\core\topicutils.pyo", line 98, in stringize
TopicNameInvalid: Topic name 1 invalid:

Can someone please point me to the doc/resolution on how I need to change mypublisher.py to keep using version 1 of pubsub.

Thanks
Werner

Try changing this to setuparg1 instead of setupv1

···

On 8/6/10 2:30 AM, werner wrote:

I recall some issue on this but can't find but the final solution is for
this.

I had in my module mypublisher.py:

from wx.lib.pubsub import Publisher
# variables instead of strings for topics
statusText = 1 # pass status text in data section
dataNeedsSaving = 2 # pass parent's name in data section to limit
propagation, e.g. self.parent.Name
etc etc

def SetDefaults():
global publisher
publisher = Publisher()

SetDefaults()

I change it to:

import wx.lib.pubsub.setupv1

--
Robin Dunn
Software Craftsman

This gives me some other errors.

Went pack through the archive again and found the one I overlooked before.

Needed to add an empty __init__.py to the folder wx.lib.pubsub.pubsub1.

To sum it again for the archive.

Previous to wxPython 2.8.11.0 I had:

from wx.lib.pubsub import Publisher
publisher = pub.Publisher()

Changes needed to work with new pubsub as of 2.8.11.0:

import wx.lib.pubsub.setupv1
from wx.lib.pubsub import pub
publisher = pub.Publisher()

Add an empty __init__.py to the folder wx.lib.pubsub.pubsub1

And add 'wx.lib.pubsub' to "packages" within your setup.py.

Werner

···

On 06/08/2010 20:44, Robin Dunn wrote:

import wx.lib.pubsub.setupv1

I change it to:

Try changing this to setuparg1 instead of setupv1

import wx.lib.pubsub.setupv1

I change it to:

Try changing this to setuparg1 instead of setupv1

This gives me some other errors.

Went pack through the archive again and found the one I overlooked before.

Needed to add an empty __init__.py to the folder wx.lib.pubsub.pubsub1.

To sum it again for the archive.

Previous to wxPython 2.8.11.0 I had:

from wx.lib.pubsub import Publisher
publisher = pub.Publisher()

Correction, above was:
publisher = Publisher()

···

On 07/08/2010 11:35, werner wrote:

On 06/08/2010 20:44, Robin Dunn wrote:

Changes needed to work with new pubsub as of 2.8.11.0:

import wx.lib.pubsub.setupv1
from wx.lib.pubsub import pub
publisher = pub.Publisher()

Add an empty __init__.py to the folder wx.lib.pubsub.pubsub1

And add 'wx.lib.pubsub' to "packages" within your setup.py.

Werner

--------------------------------------------------
From: "werner" <wbruhin@free.fr>
Sent: Saturday, August 07, 2010 10:35 AM
To: <wxpython-users@googlegroups.com>
Subject: Re: [wxPython-users] wx.lib.pubsub in wxPython 2.8.11.0 and py2exe

import wx.lib.pubsub.setupv1

I change it to:

Try changing this to setuparg1 instead of setupv1

This gives me some other errors.

Went pack through the archive again and found the one I overlooked before.

Needed to add an empty __init__.py to the folder wx.lib.pubsub.pubsub1.

To sum it again for the archive.

Previous to wxPython 2.8.11.0 I had:

from wx.lib.pubsub import Publisher
publisher = pub.Publisher()

Changes needed to work with new pubsub as of 2.8.11.0:

import wx.lib.pubsub.setupv1
from wx.lib.pubsub import pub
publisher = pub.Publisher()

Add an empty __init__.py to the folder wx.lib.pubsub.pubsub1

I have had a number of problems in the past with missing empty files - I suspect that some zip/unzip tools skip empty files on the basis that if there is nothing in them they "don't matter" - Can I suggest that it would be good practice NEVER to have empty files rather have a file that just contains a, (file type compliant), comment telling others what it is there for, this will make it clearer and since the file will not be empty, i.e. zero bytes, it should avoid any tidying up by well meaning tools. For those of us that write tools that check for empty files we should make an effort to ensure that we equate isempty and ismissing and treat them the same...

Just my 2p worth :wink:

Agree that is a good practice, mine actually has "# to make py2exe find it" in it, the point of the file is to "declare" pubsub1 as a package below the package pubsub and therefore the following line will ensure that py2exe will include it in the dist.

Werner

···

On 07/08/2010 12:36, GadgetSteve@live.co.uk wrote:

On 06/08/2010 20:44, Robin Dunn wrote:

Gadget/Steve

And add 'wx.lib.pubsub' to "packages" within your setup.py.

Werner

--
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Sorry I was away on vacation. Glad you figured it out. Also, have you tried

import wx.lib.pubsub.setuparg1

from wx.lib.pubsub import pub

publisher = pub

Oliver

···

On Sat, Aug 7, 2010 at 5:35 AM, werner wbruhin@free.fr wrote:

On 06/08/2010 20:44, Robin Dunn wrote:

import wx.lib.pubsub.setupv1

I change it to:

Try changing this to setuparg1 instead of setupv1

This gives me some other errors.

Went pack through the archive again and found the one I overlooked before.

Needed to add an empty init.py to the folder wx.lib.pubsub.pubsub1.

To sum it again for the archive.

Previous to wxPython 2.8.11.0 I had:

from wx.lib.pubsub import Publisher

publisher = pub.Publisher()

Changes needed to work with new pubsub as of 2.8.11.0:

import wx.lib.pubsub.setupv1

from wx.lib.pubsub import pub

publisher = pub.Publisher()

Add an empty init.py to the folder wx.lib.pubsub.pubsub1

And add ‘wx.lib.pubsub’ to “packages” within your setup.py.

Werner

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

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

Oliver,

Sorry I was away on vacation.

Nothing to be sorry about, I hope :wink:

Glad you figured it out. Also, have you tried

import wx.lib.pubsub.setuparg1
from wx.lib.pubsub import pub
publisher = pub

I think I did. Will leave it alone for the moment as it works, plan to move to the new api at some point in the near future anyhow.

Werner

···

On 09/08/2010 03:54, oliver wrote: