(self, tbl)
Change handler (table_attrs) of the replicated table.
Change handler (table_attrs) of the replicated table.
Change handler ( table_attrs ) of the replicated table .
def cmd_change_handler(self, tbl):
        """Change handler (table_attrs) of the replicated table."""

        self.load_local_info()

        tbl = skytools.fq_name(tbl)

        db = self.get_database('db')
        curs = db.cursor()
        q = "select table_attrs, dest_table "\
            " from londiste.get_table_list(%s) "\
            " where table_name = %s and local"
        curs.execute(q, [self.set_name, tbl])
        if curs.rowcount == 0:
            self.log.error("Table %s not found on this node", tbl)
            sys.exit(1)

        attrs, dest_table = curs.fetchone()
        attrs = skytools.db_urldecode(attrs or '')
        old_handler = attrs.get('handler')

        tgargs = self.build_tgargs()
        if self.options.handler:
            new_handler = self.build_handler(tbl, tgargs, dest_table)
        else:
            new_handler = None

        if old_handler == new_handler:
            self.log.info("Handler is already set to desired value, nothing done")
            sys.exit(0)

        if new_handler:
            attrs['handler'] = new_handler
        elif 'handler' in attrs:
            del attrs['handler']

        args = [self.set_name, tbl, tgargs, None]
        if attrs:
            args[3] = skytools.db_urlencode(attrs)

        q = "select * from londiste.local_change_handler(%s, %s, %s, %s)"
        self.exec_cmd(curs, q, args)
        db.commit()
def cmd_change_handler ( self , tbl ) : self . load_local_info ( ) tbl = skytools . fq_name ( tbl ) db = self . get_database ( 'db' ) curs = db . cursor ( ) q = "select table_attrs, dest_table " " from londiste.get_table_list(%s) " " where table_name = %s and local" curs . execute ( q , [ self . set_name , tbl ] ) if curs . rowcount == 0 : self . log . error ( "Table %s not found on this node" , tbl ) sys . exit ( 1 ) attrs , dest_table = curs . fetchone ( ) attrs = skytools . db_urldecode ( attrs or '' ) old_handler = attrs . get ( 'handler' ) tgargs = self . build_tgargs ( ) if self . options . handler : new_handler = self . build_handler ( tbl , tgargs , dest_table ) else : new_handler = None if old_handler == new_handler : self . log . info ( "Handler is already set to desired value, nothing done" ) sys . exit ( 0 ) if new_handler : attrs [ 'handler' ] = new_handler elif 'handler' in attrs : del attrs [ 'handler' ] args = [ self . set_name , tbl , tgargs , None ] if attrs : args [ 3 ] = skytools . db_urlencode ( attrs ) q = "select * from londiste.local_change_handler(%s, %s, %s, %s)" self . exec_cmd ( curs , q , args ) db . commit ( )