Design question.... parent/child class

Geert-Jan Van den Bogaerde gvdbogae at vub.ac.be
Tue Sep 3 11:41:02 EDT 2002


On Tue, 2002-09-03 at 14:56, Gumuz wrote:
> hi all,
> 
> i have a SessionManager class, which contains a list of Session
> objects(instantiated from a Session class). I have a design problem.
> 
> Each session object has a small 'queue' of messages for the specific
> session. How can a session send a message to another session without having
> some kind of parent-reference to the SessionManager object?
> 
> i am a bit puzzled, or is this parent-reference not such a bad idea after
> all?
> 

There have been other replies which might be more suited to your
situation, but if you want a very loose coupling I've found using a
signal dispatching system very effective. There is a python
implementation here:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/87056/

This is similar to Qt's signal/slot system, if you're familiar with
that. You have your session objects send a signal whenevever some
interesting event happens, and your other objects listening for the
signals they're interested in.

Best Regards,

Geert-Jan Van den Bogaerde





More information about the Python-list mailing list