(self, data)
return result
Do dml according to special field _op that must be given together wit data
Do dml according to special field _op that must be given together wit data
Do dml according to special field _op that must be given together wit data
def do(self, data):
        """ Do dml according to special field _op that must be given together wit data
        """
        result = data                               # so it is initialized for skip
        self._op = data.pop(self._ctx.OP)           # determines operation done
        self._row = data.pop(self._ctx.ROW, None)   # internal record id used for error reporting
        if self._row is None:                       # if no _row variable was provided
            self._row = data.get(self._id, None)    # use id instead
        if self._id in data and data[self._id]:     # if _id field is given
            if int( data[self._id] ) < 0:           # and it is fake key generated by ui
                data.pop(self._id)                  # remove fake key so real one can be assigned
        version = data.get('version', None)         # version sent from caller
        data['version'] = self._ctx.version         # current transaction id is stored in each record
        if   self._op == self._ctx.INSERT: result = self._insert( data )
        elif self._op == self._ctx.UPDATE: result = self._update( data, version )
        elif self._op == self._ctx.DELETE: result = self._delete( data, version )
        elif self._op == self._ctx.SKIP:   None
        else:
            self._ctx.tell_user( self._ctx.ERROR, "dbsXXXX",
                "Unahndled _op='{op}' value in TableAPI (table={table}, id={id})",
                op = self._op, table = self._table, id = data[self._id] )
        result[self._ctx.OP] = self._op
        result[self._ctx.ROW] = self._row
        return result
def do ( self , data ) : result = data # so it is initialized for skip self . _op = data . pop ( self . _ctx . OP ) # determines operation done self . _row = data . pop ( self . _ctx . ROW , None ) # internal record id used for error reporting if self . _row is None : # if no _row variable was provided self . _row = data . get ( self . _id , None ) # use id instead if self . _id in data and data [ self . _id ] : # if _id field is given if int ( data [ self . _id ] ) < 0 : # and it is fake key generated by ui data . pop ( self . _id ) # remove fake key so real one can be assigned version = data . get ( 'version' , None ) # version sent from caller data [ 'version' ] = self . _ctx . version # current transaction id is stored in each record if self . _op == self . _ctx . INSERT : result = self . _insert ( data ) elif self . _op == self . _ctx . UPDATE : result = self . _update ( data , version ) elif self . _op == self . _ctx . DELETE : result = self . _delete ( data , version ) elif self . _op == self . _ctx . SKIP : None else : self . _ctx . tell_user ( self . _ctx . ERROR , "dbsXXXX" , "Unahndled _op='{op}' value in TableAPI (table={table}, id={id})" , op = self . _op , table = self . _table , id = data [ self . _id ] ) result [ self . _ctx . OP ] = self . _op result [ self . _ctx . ROW ] = self . _row return result