Changeset 142

Show
Ignore:
Timestamp:
05/06/02 18:13:12 (6 years ago)
Author:
sholloway
Message:

Bugfix to make WeakBind? derived objects work with ContextApply?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBFoundation/RBFoundation/WeakBind.py

    r139 r142  
    5656 
    5757class BoundCallable(BoundCallableBase): 
     58    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     59    #~ Constants / Variables / Etc.  
     60    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     61 
    5862    im_self = None 
    5963    im_func = None 
    6064 
     65    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     66    #~ Special  
     67    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     68 
    6169    def __init__(self, callback): 
    62         if callback is None: 
    63             self.im_func = None 
     70        if callback is None:  
     71            # A "None" method... it should expire immediately 
     72            pass 
     73        elif isinstance(callback, BoundCallableBase): 
     74            # One of those weird instances where we are proxying for an object very similar to ourself...  
     75            # keep a hard reference to the BoundCallableBase 
     76            self.im_func = callback 
    6477        elif isinstance(callback, typesMethods): 
     78            # Wrap up the method and potential instance 
    6579            if callback.im_self is not None:  
    6680                self.im_self = weakref.ref(callback.im_self) 
    6781            self.im_func = callback.im_func 
    6882        elif isinstance(callback, typesInstances): 
     83            # This is a "callable object", make a weakref to it 
    6984            self.im_self = weakref.ref(callback) 
    7085            self.im_func = None 
    71         else: 
     86        elif callable(callback): 
     87            # What the heck is it?  well... its supposed to be callable... 
    7288            self.im_func = callback 
    7389