On Tue, 2005-02-22 at 15:22, Pascal Peregrina wrote:
Ok, so, this almost completely answers my question.
Let me tell you more about what I am doing, because I agree that my initial mail was not that clear. :)
I am trying to implement a ZeroConf browser (http://www.zeroconf.org/) in Zope to automatically get the network location of XML RPC services that my Zope objects talk to.
The ZMI part is easy. In my new product, I've got my object in the Control Panel, and it is ready to display whatever data I want (for example the list of discovered services).
The ZeroConf implementation itself has already been made by someone else (http://sourceforge.net/projects/pyzeroconf)
So I am just trying to plug pieces together now :)
From my product, I need to start a thread that will run the ZeroConf code, and ZeroConf data will then be accessible through a particular object of this code (the "listener" to be exact, as they call it in pyzeronf).
This thread should be started when Zope starts, so I guess I can put it in the __init__.py of my product.
I only got one issue : my product can be refreshed. So how can I ensure that the ZeroConf stuff won't be re-initialized if I refresh my product ? (ending with 2 threads, with one of the threads not being used). I know this is more a python related question, but I haven't found a precise answer on the net.
I'm not sure of how the internals of refresh work (I dont use it) but I suspect that if you do something like: import sys if not getattr(sys, 'ZEROCONF_STARTED'): .. start the thread .. sys.ZEROCONF_STARTED = 1 It will not spawn another thread. "sys" is just an example here, any module namespace should work (even __builtins__ probably).