예제 #1
0
파일: __init__.py 프로젝트: navtej/toolbag
 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
예제 #2
0
 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
예제 #3
0
    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
예제 #4
0
파일: __init__.py 프로젝트: navtej/toolbag
 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]
예제 #5
0
 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]
예제 #6
0
 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