예제 #1
0
class Collection(object):
    def __init__(self, collection={}):
        self.onAdded = EventHook()
        self.onRemoved = EventHook()
        self._collection = collection

    def get(self, ID):
        return self._collection[ID]

    def add(self, obj):
        self._collection[obj['ID']] = obj
        self.onAdded.fire(ID=obj['ID'])

    def remove(self, ID):
        del self._collection[ID]
        self.onRemoved.fire(ID=ID)

    def collection(self):
        return self._collection
예제 #2
0
class Collection(object):

    def __init__(self, collection = {}):
        self.onAdded = EventHook()
        self.onRemoved = EventHook()
        self._collection = collection

    def get(self, ID):
        return self._collection[ID];

    def add(self, obj):
        self._collection[obj['ID']] = obj
        self.onAdded.fire(ID=obj['ID'])

    def remove(self, ID):
        del self._collection[ID]
        self.onRemoved.fire(ID=ID)

    def collection(self):
        return self._collection
예제 #3
0
 def __init__(self, collection={}):
     self.onAdded = EventHook()
     self.onRemoved = EventHook()
     self._collection = collection
예제 #4
0
 def __init__(self, collection = {}):
     self.onAdded = EventHook()
     self.onRemoved = EventHook()
     self._collection = collection