Yeah, just keep a list of functions in your own code, no need to use twisted for it and I&#39;ve not seen twisted functions that really help.&nbsp; something like:<br><br>class event(object):<br>&nbsp; def __init__(self):<br>&nbsp;&nbsp;&nbsp; self.subscribers=[]<br>
&nbsp; def subscribe(self.f):<br>&nbsp;&nbsp;&nbsp; self.subscribers.append(f)<br>&nbsp; def invoke(self,*args,*kwargs):<br>&nbsp;&nbsp;&nbsp; for function in subscribers:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; function(*args,**kwargs)<br><br>you can tweak that or whatever, but that&#39;s the basic pythonic way to do it in my book(and in my code) a couple options to consider:<br>
* in invoke, pass self to the function, I usually do that so I can have functions that do whatever they do to the &quot;event&quot; subclass itself, as in a clearOnFocus function attached to a text control which subclasses event, whenever certain data is seen (type=focusEvent) clear the control.<br>
* instead of storing functions store and .callback deffereds, of course those can only be used once so change event.subscribe to event.wait for clarity and reinitialize the list after invoke.<br><br>-Andy Fundinger<br><br>
<div class="gmail_quote">On Jan 30, 2008 3:15 PM, Simon Pickles &lt;<a href="mailto:sipickles@hotmail.com">sipickles@hotmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I have a stackless python app, using twisted in parts (.internet and<br>.adbapi).<br><br>I need a little help getting pythonic after years of c++ hell.<br><br>I&#39;d like to use a system of events and observers, like c++ boost.signal.<br>
<br>I&#39;d like to be able to subscribe multiple callbacks to a single function<br>and cal them all using something like:<br><br>event.invoke(&quot;some data to send with invocation&quot;)<br><br>I&#39;m thinking twisted callbacks do this:<br>
<br>&nbsp;def observe(self, f);<br> &nbsp; &nbsp; &nbsp;self.event.addcallback(f)<br><br>Are there other ways?<br><br>Thanks<br><br>Si<br><br>--<br>Linux user #458601 - <a href="http://counter.li.org" target="_blank">http://counter.li.org</a>.<br>
<br><br><br><br>_______________________________________________<br>Twisted-Python mailing list<br><a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br><a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Blog: &nbsp;<a href="http://channel3b.wordpress.com">http://channel3b.wordpress.com</a><br>Second Life Name: &nbsp;Ciemaar Flintoff<br><br>I am a sig Virus. Please put me in your sig so that I can continue to replicate.