[Twisted-Python] notifyOnDisconnect

Itamar Shtull-Trauring itamar at itamarst.org
Fri Sep 12 20:17:56 MDT 2003


On Fri, 05 Sep 2003 12:20:20 +0300
Ruslan Spivak <alienoid at is.lg.ua> wrote:

> I have server and a lot of clients, that connects to server and pass 
> their pb.Referenceable. Every 2 minutes server calls clients' remote 
> method. I store clients' references on server in a list of
> dictionaries - [{'remoteRef' : ref, 'ip' : '192.168.1.2', 'mac' :
> '...'}, ....] I call notifyOnDisconnect on clients' remoteRef. In
> callback i need to close client's firewall. How can i pass 'ip', 'mac'
> from dictionary to callback if notifyOnDisconnect passes only one
> parameter(this instance) to callback method. Help, please

notifyOnDisconnect(lambda x: x.disconnected({'remoteRef' : ref, 'ip' :
'192.168.1.2', 'mac' : '...'})

or maybe

notifyOnDisconnect(lambda: x.disconnected({'remoteRef' : ref, 'ip' :
'192.168.1.2', 'mac' : '...'})

depending on the required signature. Use a lambda, anyway.

-- 
Itamar Shtull-Trauring    http://itamarst.org/
Available for Python & Twisted consulting




More information about the Twisted-Python mailing list