Esempio n. 1
0
    def __init__(self, obj, callback=None, **kwargs): #{{{
        self.__name__ = getattr(obj, '__name__', 'UnnamedCallable')
        isw = needs_wrapping(obj)
        obj = callableobj(obj)
        if not obj:
            raise TypeError('Argument must be a valid callable object')
        elif callback is not None and not iscallable(callback):
            raise TypeError('callback argument must be a callable object')

        self._object = None
        self._function = None
        self._newcall = self.call
        self._numargs, self._maxargs = num_static_args(obj)
        isweak = bool(kwargs.get('weak', True))
        if isw:
            isweak = False

        mtype = methodtype(obj)
        self._methodtype = mtype
        if mtype not in (METHODTYPE_NOTMETHOD, METHODTYPE_UNBOUND):
            o = obj.im_class
            if mtype == METHODTYPE_INSTANCE:
                o = obj.im_self
            self._object = cref(o, callback, weak=isweak)
            self._function = obj.im_func
        else:
            self._function = cref(obj, callback, weak=isweak)
        self._funcid = cid(obj)
Esempio n. 2
0
 def fset(self, val): #{{{
     vars = self._vars
     if vars['sigfunc'] is not None:
         raise ValueError("Can only set 'signalfunc' property once")
     if not iscallable(val) or getattr(val, 'signal', None) is not self:
         raise TypeError('Attempt to set invalid signalfunc')
     vars['sigfunc'] = cref(val)