def work(self): obj = self.obj() wrapped = self.wrapped() if obj is not None and wrapped is not None: from public import get_wrapper to = set(get_wrapper(wrapped)) self.fn(wrapped, to, obj)
def unsubscribe(self, obj): wr = get_wrapper(obj) self._unsubscribe(wr) keys = wr._unsubscribe(self) keys.append(self._names[wr]) for key in keys: self._dict.pop(key, None)
def __setitem__(self, key, obj): wr = get_wrapper(obj) self._names[wr] = key self._subscribe(wr) keys = wr._subscribe(self) keys.append(key) assert not(key != '_' and key in self._dict), 'same name' for key in keys: self._dict[key] = wr.obj return obj
def wrapper(self, *args, **kwargs): to = kwargs.pop('to', None) if to is None: to = set(get_wrapper(self)) elif isinstance(to, base.Wrapper): to = set(to) elif isinstance(to, base.Subscriber): to = set((to,)) else: raise if not to: return fn(self, to, *args, **kwargs)
def wrapper(self, *args, **kwargs): if params['Wrapper'] is not False: wr = get_wrapper(self, True) if wr is None or wr.obj is None: params['Wrapper'](self) old_init(self, *args, **kwargs)