Properties, Methods, Events

Delaney, Timothy tdelaney at avaya.com
Thu May 10 00:17:25 EDT 2001


> 2. If the proxied object's method then calls one of its own 
> methods, the event handler will not be fired.
> 
> There are a couple of ways you could deal with #2. One I can 
> think of off-hand only works with single-threading. When a 
> method call is made, actually replace *all* the methods of 
> the proxied object with ones which call the event handlers, 
> and restore them once the method call is complete (would 
> require try...finally). In a multi-threaded situation though 
> this could be dangerous ... especially if you have multiple 
> EventProxy objects proxying the same object.

Forgot to mention - it would also be necessary to replace the proxied
object's __getattr__ in order to catch any attributes which were generated
dynamically.

And my code will only currently work for callable attributes of a proxied
objects. I said it was quickly thrown together ...

Tim Delaney




More information about the Python-list mailing list