<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def commit_operation( self, input_op_data, accepted_nameop, current_block_number ):
 """ Commit an operation, thereby carrying out a state transition. Returns a dict with the new db record fields """

   
        # have to have read-write disposition 
        if self.disposition != DISPOSITION_RW:
            log.error("FATAL: borrowing violation: not a read-write connection")
            traceback.print_stack()
            os.abort()

        cur = self.db.cursor()
        canonical_op = None
        op_type_str = None      # for debugging
        opcode = accepted_nameop.get('opcode', None)

        try:
            assert opcode is not None, "Undefined op '%s'" % accepted_nameop['op']
        except Exception, e:
            log.exception(e)
            log.error("FATAL: unrecognized op '%s'" % accepted_nameop['op'] )
            os.abort()

        if opcode in OPCODE_PREORDER_OPS:
            # preorder
            canonical_op = self.commit_state_preorder( accepted_nameop, current_block_number )
            op_type_str = "state_preorder"
            
        elif opcode in OPCODE_CREATION_OPS:
            # creation
            canonical_op = self.commit_state_create( accepted_nameop, current_block_number )
            op_type_str = "state_create"
           
        elif opcode in OPCODE_TRANSITION_OPS:
            # transition 
            canonical_op = self.commit_state_transition( accepted_nameop, current_block_number )
            op_type_str = "state_transition"
       
        elif opcode in OPCODE_TOKEN_OPS:
            # token operation 
            canonical_op = self.commit_token_operation(accepted_nameop, current_block_number)
            op_type_str = "token_operation"

        else:
            raise Exception("Unknown operation {}".format(opcode))

        if canonical_op is None:
            log.error("FATAL: no canonical op generated (for {})".format(op_type_str))
            os.abort()
        
        log.debug("Extract consensus fields for {} in {}, as part of a {}".format(opcode, current_block_number, op_type_str))
        consensus_op = self.extract_consensus_op(opcode, input_op_data, canonical_op, current_block_number)
        return consensus_op