def do_set_expr(self, expr): # find dependencies and error-check expression #try: data = asarray(self.worksheet.evaluate(expr)) # except Exception, ar: # x. print >>sys.stderr, '*****************', ar # raise UserWarning, False self.depdict = self.analyze_expression(expr) newdep = set(self.depdict.values()) # set dependencies for column in newdep - self.dependencies: print >>sys.stderr, "add", column.name dispatcher.connect(self.calculate, signal='data-changed', sender=column) dispatcher.connect(self.on_dep_rename, signal='rename', sender=column) for column in self.dependencies - newdep: print >>sys.stderr, "rem", column.name dispatcher.disconnect(self.calculate, signal='data-changed', sender=column) dispatcher.disconnect(self.on_dep_rename, signal='rename', sender=column) newdepws = set(d.worksheet for d in newdep) depws = set(d.worksheet for d in self.dependencies) for worksheet in newdepws - depws: dispatcher.connect(self.on_dep_ws_rename, signal='fullname-changed', sender=worksheet) dispatcher.connect(self.on_dep_ws_rename, signal='rename', sender=worksheet) for worksheet in depws - newdepws: dispatcher.disconnect(self.on_dep_ws_rename, signal='fullname-changed', sender=worksheet) dispatcher.disconnect(self.on_dep_ws_rename, signal='rename', sender=worksheet) self.dependencies = newdep if expr != '': # set data without triggering an action self.data[:] = data dispatcher.send(sender=self, signal='data-changed') dispatcher.send(sender=self.worksheet, signal='data-changed') return True
def receiveDrop(self, sender, signal, model): if sender is self: return for observer in self.observers: dispatcher.disconnect(observer.receivePropertyChange, signal=model) self.models.remove(model)
def unregisterObserver(self, observer): dispatcher.disconnect(observer.receiveDropModel, signal=Drop) dispatcher.disconnect(observer.receiveNewModel, signal=New) for model in self.models: dispatcher.disconnect(observer.receivePropertyChange, signal=model) self.observers.remove(observer)