def __init__(self, type, default=None, nillable=False):
     if default is None and not nillable:
         raise TypeError("default must be specified if object is not nillable")
     self.type = type
     self.default = default
     self.nillable = nillable
     self.values = weakobjectmap()
     self.oldvalues = weakobjectmap()
     self.dirty = weakobjectmap()
     self.lock = Lock()
Example #2
0
 def __init__(self, type, default=None, nillable=False):
     if default is None and not nillable:
         raise TypeError("default must be specified if object is not nillable")
     self.type = type
     self.default = default
     self.nillable = nillable
     self.values = weakobjectmap()
     self.oldvalues = weakobjectmap()
     self.dirty = weakobjectmap()
     self.lock = Lock()
class ObserverWeakrefProxy(object):
    """
    A proxy that allows an observer to be weakly referenced and automatically
    removes any remaining registrations that the observer didn't clean itself
    before its reference count dropped to zero.
    """

    implements(IObserver)

    observer_map = weakobjectmap()
    lock = Lock()

    def __new__(cls, observer):
        if not IObserver.providedBy(observer):
            raise TypeError('observer must implement the IObserver interface')
        with cls.lock:
            if observer in cls.observer_map:
                return cls.observer_map[observer]
            instance = object.__new__(cls)
            instance.observer_ref = weakref.ref(observer, instance.cleanup)
            cls.observer_map[observer] = instance
            return instance

    # noinspection PyUnusedLocal
    def cleanup(self, ref):
        # remove all observer's remaining registrations (the ones that the observer didn't remove itself)
        for notification_center in NotificationCenter.__instances__.itervalues(
        ):
            notification_center.purge_observer(self)

    def handle_notification(self, notification):
        observer = self.observer_ref()
        if observer is not None:
            observer.handle_notification(notification)
Example #4
0
 def __init__(self, name, type, required=False, test_equal=True, onset=None, ondel=None):
     self.name = name
     self.type = type
     self.required = required
     self.test_equal = test_equal
     self.onset = onset
     self.ondel = ondel
     self.values = weakobjectmap()
Example #5
0
 def __init__(self, name, type, required=False, test_equal=True, onset=None, ondel=None):
     self.name = name
     self.type = type
     self.required = required
     self.test_equal = test_equal
     self.onset = onset
     self.ondel = ondel
     self.values = weakobjectmap()
Example #6
0
 def __init__(self, name, xmlname=None, type=unicode, default=None, required=False, test_equal=True, onset=None, ondel=None):
     self.name = name
     self.xmlname = xmlname or name
     self.type = type
     self.default = default
     self.__xmlparse__ = getattr(type, '__xmlparse__', lambda value: value)
     self.__xmlbuild__ = getattr(type, '__xmlbuild__', unicode)
     self.required = required
     self.test_equal = test_equal
     self.onset = onset
     self.ondel = ondel
     self.values = weakobjectmap()
Example #7
0
 def __init__(cls, name, bases, dct):
     super(SettingsGroupMeta, cls).__init__(name, bases, dct)
     cls.values = weakobjectmap()
Example #8
0
 def __init__(self, type):
     self.type = type
     self.values = weakobjectmap()
     self.lock = Lock()
Example #9
0
 def __init__(self, func):
     self.__func__ = func
     self.__callmap__ = weakobjectmap()
     self.__callmap__[func] = False
     self.lock = RLock()
 def __init__(self):
     self.values = weakobjectmap()
Example #11
0
 def __init__(self):
     self.object_map = weakobjectmap()
 def __init__(self):
     self.values = weakobjectmap()
Example #13
0
 def __init__(cls, name, bases, dct):
     super(SettingsGroupMeta, cls).__init__(name, bases, dct)
     cls.values = weakobjectmap()
Example #14
0
 def __init__(self, type):
     self.type = type
     self.values = weakobjectmap()
     self.lock = Lock()
Example #15
0
 def __init__(self):
     self.object_map = weakobjectmap()
Example #16
0
 def __init__(self, func):
     self.__func__ = func
     self.__callmap__ = weakobjectmap()
     self.__callmap__[func] = False
     self.lock = RLock()