Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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
Пример #4
0
    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)
Пример #5
0
 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)