nodes: 0, module; 1, function_definition; 2, function_name:render_table; 3, parameters; 4, block; 5, identifier:request; 6, identifier:table; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, default_parameter; 12, comment:# pragma: no mutate; 13, default_parameter; 14, default_parameter; 15, default_parameter; 16, default_parameter; 17, default_parameter; 18, expression_statement; 19, if_statement; 20, if_statement; 21, assert_statement; 22, expression_statement; 23, expression_statement; 24, if_statement; 25, expression_statement; 26, expression_statement; 27, expression_statement; 28, if_statement; 29, expression_statement; 30, if_statement; 31, if_statement; 32, return_statement; 33, identifier:links; 34, None; 35, identifier:context; 36, None; 37, identifier:template; 38, string; 39, identifier:blank_on_empty; 40, False; 41, identifier:paginate_by; 42, integer:40; 43, identifier:page; 44, None; 45, identifier:paginator; 46, None; 47, identifier:show_hits; 48, False; 49, identifier:hit_label; 50, string; 51, identifier:post_bulk_edit; 52, lambda; 53, comment:"""
      Render a table. This automatically handles pagination, sorting, filtering and bulk operations.
  
      :param request: the request object. This is set on the table object so that it is available for lambda expressions.
      :param table: an instance of Table
      :param links: a list of instances of Link
      :param context: dict of extra context parameters
      :param template: if you need to render the table differently you can override this parameter with either a name of a template to load or a `Template` instance.
      :param blank_on_empty: turn off the displaying of `{{ empty_message }}` in the template when the list is empty
      :param show_hits: Display how many items there are total in the paginator.
      :param hit_label: Label for the show_hits display.
      :return: a string with the rendered HTML table
      """; 54, not_operator; 55, block; 56, call; 57, block; 58, call; 59, identifier:table; 60, assignment; 61, assignment; 62, identifier:should_return; 63, block; 64, assignment; 65, assignment; 66, assignment; 67, boolean_operator; 68, block; 69, assignment; 70, boolean_operator; 71, block; 72, boolean_operator; 73, block; 74, call; 75, string_content:tri_table/list.html; 76, string_content:Items; 77, lambda_parameters; 78, None; 79, identifier:context; 80, expression_statement; 81, identifier:isinstance; 82, argument_list; 83, expression_statement; 84, identifier:isinstance; 85, argument_list; 86, attribute; 87, identifier:request; 88, pattern_list; 89, call; 90, return_statement; 91, subscript; 92, attribute; 93, subscript; 94, attribute; 95, subscript; 96, attribute; 97, attribute; 98, comparison_operator:request.method == 'POST'; 99, if_statement; 100, attribute; 101, call; 102, not_operator; 103, identifier:blank_on_empty; 104, return_statement; 105, attribute; 106, not_operator; 107, expression_statement; 108, expression_statement; 109, identifier:render_template; 110, argument_list; 111, identifier:table; 112, identifier:queryset; 113, identifier:updates; 114, assignment; 115, identifier:table; 116, identifier:Namespace; 117, assignment; 118, identifier:table; 119, identifier:Table; 120, identifier:table; 121, identifier:request; 122, identifier:should_return; 123, identifier:dispatch_result; 124, identifier:handle_dispatch; 125, argument_list; 126, identifier:dispatch_result; 127, identifier:context; 128, string; 129, identifier:table; 130, identifier:bulk_form; 131, identifier:context; 132, string; 133, identifier:table; 134, identifier:query_form; 135, identifier:context; 136, string; 137, identifier:table; 138, identifier:query_error; 139, identifier:table; 140, identifier:bulk_form; 141, attribute; 142, string; 143, call; 144, block; 145, identifier:table; 146, identifier:context; 147, identifier:table_context; 148, argument_list; 149, attribute; 150, string; 151, identifier:table; 152, identifier:query_form; 153, call; 154, assignment; 155, assignment; 156, identifier:request; 157, identifier:template; 158, attribute; 159, identifier:context; 160, dictionary; 161, identifier:table; 162, call; 163, keyword_argument; 164, keyword_argument; 165, string_content:bulk_form; 166, string_content:query_form; 167, string_content:tri_query_error; 168, identifier:request; 169, identifier:method; 170, string_content:POST; 171, attribute; 172, argument_list; 173, expression_statement; 174, expression_statement; 175, expression_statement; 176, expression_statement; 177, return_statement; 178, identifier:request; 179, keyword_argument; 180, keyword_argument; 181, keyword_argument; 182, keyword_argument; 183, keyword_argument; 184, keyword_argument; 185, keyword_argument; 186, keyword_argument; 187, identifier:table; 188, identifier:data; 189, attribute; 190, argument_list; 191, attribute; 192, None; 193, subscript; 194, call; 195, identifier:table; 196, identifier:context; 197, identifier:table; 198, argument_list; 199, identifier:request; 200, identifier:request; 201, identifier:obj; 202, identifier:table; 203, attribute; 204, identifier:is_valid; 205, assignment; 206, assignment; 207, call; 208, call; 209, call; 210, identifier:table; 211, identifier:table; 212, identifier:links; 213, identifier:links; 214, identifier:paginate_by; 215, identifier:paginate_by; 216, identifier:page; 217, identifier:page; 218, identifier:extra_context; 219, identifier:context; 220, identifier:paginator; 221, identifier:paginator; 222, identifier:show_hits; 223, identifier:show_hits; 224, identifier:hit_label; 225, identifier:hit_label; 226, attribute; 227, identifier:is_valid; 228, identifier:table; 229, identifier:data; 230, attribute; 231, string; 232, identifier:mark_safe; 233, argument_list; 234, identifier:table; 235, identifier:bulk_form; 236, identifier:queryset; 237, call; 238, identifier:updates; 239, dictionary_comprehension; 240, attribute; 241, argument_list; 242, identifier:post_bulk_edit; 243, argument_list; 244, identifier:HttpResponseRedirect; 245, argument_list; 246, identifier:table; 247, identifier:query_form; 248, identifier:table; 249, identifier:context; 250, string_content:invalid_form_message; 251, string:'<i class="fa fa-meh-o fa-5x" aria-hidden="true"></i>'; 252, attribute; 253, argument_list; 254, pair; 255, for_in_clause; 256, if_clause; 257, identifier:queryset; 258, identifier:update; 259, dictionary_splat; 260, keyword_argument; 261, keyword_argument; 262, keyword_argument; 263, subscript; 264, identifier:table; 265, identifier:bulk_queryset; 266, attribute; 267, attribute; 268, identifier:field; 269, attribute; 270, boolean_operator; 271, identifier:updates; 272, identifier:table; 273, identifier:table; 274, identifier:queryset; 275, identifier:queryset; 276, identifier:updates; 277, identifier:updates; 278, attribute; 279, string; 280, identifier:field; 281, identifier:name; 282, identifier:field; 283, identifier:value; 284, attribute; 285, identifier:fields; 286, boolean_operator; 287, comparison_operator:field.attr is not None; 288, identifier:request; 289, identifier:META; 290, string_content:HTTP_REFERER; 291, identifier:table; 292, identifier:bulk_form; 293, comparison_operator:field.value is not None; 294, comparison_operator:field.value != ''; 295, attribute; 296, None; 297, attribute; 298, None; 299, attribute; 300, string; 301, identifier:field; 302, identifier:attr; 303, identifier:field; 304, identifier:value; 305, identifier:field; 306, identifier:value
code: def render_table(request,
                   table,
                   links=None,
                   context=None,
                   template='tri_table/list.html',
                   blank_on_empty=False,
                   paginate_by=40,  # pragma: no mutate
                   page=None,
                   paginator=None,
                   show_hits=False,
                   hit_label='Items',
                   post_bulk_edit=lambda table, queryset, updates: None):
      """
      Render a table. This automatically handles pagination, sorting, filtering and bulk operations.
  
      :param request: the request object. This is set on the table object so that it is available for lambda expressions.
      :param table: an instance of Table
      :param links: a list of instances of Link
      :param context: dict of extra context parameters
      :param template: if you need to render the table differently you can override this parameter with either a name of a template to load or a `Template` instance.
      :param blank_on_empty: turn off the displaying of `{{ empty_message }}` in the template when the list is empty
      :param show_hits: Display how many items there are total in the paginator.
      :param hit_label: Label for the show_hits display.
      :return: a string with the rendered HTML table
      """
      if not context:
          context = {}
  
      if isinstance(table, Namespace):
          table = table()
  
      assert isinstance(table, Table), table
      table.request = request
  
      should_return, dispatch_result = handle_dispatch(request=request, obj=table)
      if should_return:
          return dispatch_result
  
      context['bulk_form'] = table.bulk_form
      context['query_form'] = table.query_form
      context['tri_query_error'] = table.query_error
  
      if table.bulk_form and request.method == 'POST':
          if table.bulk_form.is_valid():
              queryset = table.bulk_queryset()
  
              updates = {
                  field.name: field.value
                  for field in table.bulk_form.fields
                  if field.value is not None and field.value != '' and field.attr is not None
              }
              queryset.update(**updates)
  
              post_bulk_edit(table=table, queryset=queryset, updates=updates)
  
              return HttpResponseRedirect(request.META['HTTP_REFERER'])
  
      table.context = table_context(
          request,
          table=table,
          links=links,
          paginate_by=paginate_by,
          page=page,
          extra_context=context,
          paginator=paginator,
          show_hits=show_hits,
          hit_label=hit_label,
      )
  
      if not table.data and blank_on_empty:
          return ''
  
      if table.query_form and not table.query_form.is_valid():
          table.data = None
          table.context['invalid_form_message'] = mark_safe('<i class="fa fa-meh-o fa-5x" aria-hidden="true"></i>')
  
      return render_template(request, template, table.context)