(self, ev)
Store new event.
Store new event.
Store new event .
def add_event(self, ev):
        """Store new event."""

        # op & data
        ev.op = ev.ev_type[0]
        ev.data = skytools.db_urldecode(ev.ev_data)

        # get pkey column names
        if self.pkey_str is None:
            if len(ev.ev_type) > 2:
                self.pkey_str = ev.ev_type.split(':')[1]
            else:
                self.pkey_str = ev.ev_extra2

            if self.pkey_str:
                self.pkey_list = self.pkey_str.split(',')

        # get pkey value
        if self.pkey_str:
            pk_data = []
            for k in self.pkey_list:
                pk_data.append(ev.data[k])
            ev.pk_data = tuple(pk_data)
        elif ev.op == 'I':
            # fake pkey, just to get them spread out
            ev.pk_data = ev.id
        else:
            raise Exception('non-pk tables not supported: %s' % self.name)

        # get full column list, detect added columns
        if not self.col_list:
            self.col_list = ev.data.keys()
        elif self.col_list != ev.data.keys():
            # ^ supposedly python guarantees same order in keys()

            # find new columns
            for c in ev.data.keys():
                if c not in self.col_list:
                    for oldev in self.ev_list:
                        oldev.data[c] = None
            self.col_list = ev.data.keys()

        # add to list
        self.ev_list.append(ev)

        # keep all versions of row data
        if ev.pk_data in self.pkey_map:
            self.pkey_map[ev.pk_data].append(ev)
        else:
            self.pkey_map[ev.pk_data] = [ev]
def add_event ( self , ev ) : # op & data ev . op = ev . ev_type [ 0 ] ev . data = skytools . db_urldecode ( ev . ev_data ) # get pkey column names if self . pkey_str is None : if len ( ev . ev_type ) > 2 : self . pkey_str = ev . ev_type . split ( ':' ) [ 1 ] else : self . pkey_str = ev . ev_extra2 if self . pkey_str : self . pkey_list = self . pkey_str . split ( ',' ) # get pkey value if self . pkey_str : pk_data = [ ] for k in self . pkey_list : pk_data . append ( ev . data [ k ] ) ev . pk_data = tuple ( pk_data ) elif ev . op == 'I' : # fake pkey, just to get them spread out ev . pk_data = ev . id else : raise Exception ( 'non-pk tables not supported: %s' % self . name ) # get full column list, detect added columns if not self . col_list : self . col_list = ev . data . keys ( ) elif self . col_list != ev . data . keys ( ) : # ^ supposedly python guarantees same order in keys() # find new columns for c in ev . data . keys ( ) : if c not in self . col_list : for oldev in self . ev_list : oldev . data [ c ] = None self . col_list = ev . data . keys ( ) # add to list self . ev_list . append ( ev ) # keep all versions of row data if ev . pk_data in self . pkey_map : self . pkey_map [ ev . pk_data ] . append ( ev ) else : self . pkey_map [ ev . pk_data ] = [ ev ]