def unset(self, *names): if names: result = self.store.driver.ctx_remove( self.store.session, query._and(query.address(self.id), query.attribute(*names)) ) else: result = self.store.driver.ctx_remove(self.store.session, query._and(query.address(self.id))) return result
def unset(self, *names): if names: result = self.store.driver.ctx_remove( self.store.session, query._and(query.address(self.id), query.attribute(*names))) else: result = self.store.driver.ctx_remove( self.store.session, query._and(query.address(self.id))) return result
def update(self): ''' call this every once in a while ''' # context if not self.watch: logging.info('refusing to update due to an empty tag list') return {} # query all contexts and update nodes result = {} for k,v in self.store.select(query.newer(self.__age),query.attribute(*self.watch),query.address(*self.node.keys())).iteritems(): if not v: continue self.node[k].update(v) result[k] = v # execute callback for all nodes for address,updates in result.iteritems(): node = self.node[address] if self.trigger.execute(node.id, node, updates): logging.warning('callback for %x returned non-zero value') continue completed = set(result.keys()) # now for content for address in self.node: result = self.store.select_content(query.newer(self.__age),query.attribute(*self.watch),query.context(address)) node = self.node[address] names = set() # collect names for updates for ea,d in result.iteritems(): names.update(d.keys()) # callbacks for content for n in names: r = ((ea,d[n]) for ea,d in result.iteritems() if n in d) self.trigger.execute((node.id,n), (node,n), dict(r)) node.content.update(result) self.__age = datetime.now() return completed
def get(self, *names): if names: result = self.store.driver.con_select( self.store.session, query._and(query.context(self.context.id), query.address(self.id), query.attribute(*names)), ) else: result = self.store.driver.con_select( self.store.session, query._and(query.context(self.context.id), query.address(self.id)) ) return result[self.id]
def get(self, *names): if names: result = self.store.driver.con_select( self.store.session, query._and(query.context(self.context.id), query.address(self.id), query.attribute(*names))) else: result = self.store.driver.con_select( self.store.session, query._and(query.context(self.context.id), query.address(self.id))) return result[self.id]
def discard_content(self, node, *tags): r = self.render.address(node.id) for ea in r.select(query.attribute(*tags)): [del(r.address(ea)[n]) for n in tags] [self.watch.discard(n) for n in tags] return