lino.core.tablerequest

Defines the TableRequest class.

(This module's source code is available here.)

Functions

column_header(col)

Classes

TableRequest([actor, unused_request, ...])

A specialized ActionRequest whose actor is a table.

class lino.core.tablerequest.TableRequest(actor=None, unused_request=None, action=None, unused_renderer=None, rqdata=None, **kw)

Bases: lino.core.requests.ActionRequest

A specialized ActionRequest whose actor is a table.

execute()

This will actually call the get_data_iterator() and run the database query.

Automatically called when either data_iterator or sliced_data_iterator is accesed.

get_total_count()

Calling len() on a QuerySet would execute the whole SELECT. See /blog/2012/0124

parse_req(request, rqdata, **kw)

Parse the incoming HttpRequest and translate it into keyword arguments to be used by setup().

The mt url param is parsed only when needed. Usually it is not needed because the master_class is constant and known per actor. But there are exceptions:

  • master is ContentType

  • master is some abstract model

  • master is not a subclass of Model, e.g. lino_xl.lib.polls.models.AnswersByResponse, a virtual table which defines get_row_by_pk.

to_rst(*args, **kw)

Returns a string representing this table request in reStructuredText markup.

table2rst(*args, **kwargs)

Print a reStructuredText representation of this table request to stdout.

table2xhtml(**kwargs)

Return an HTML representation of this table request.

dump2html(tble, data_iterator, column_names=None, header_links=False, hide_sums=None)

Render this table into an existing etgen.html.Table instance. This is central method is used by all Lino renderers.

Arguments:

tble An instance of etgen.html.Table.

data_iterator the iterable provider of table rows. This can be a queryset or a list.

column_names is an optional string with space-separated column names. If this is None, the table's column_names is used.

header_links says whether to render column headers clickable with a link that sorts the table.

hide_sums : whether to hide sums. If this is not given, use the hide_sums of the actor.

get_field_info(column_names=None)

Return a tuple (fields, headers, widths) which expresses which columns, headers and widths the user wants for this request. If self has web request info (request is not None), checks for GET parameters cn, cw and ch. Also calls the tables's override_column_headers method.

row2text(fields, row, sums)

Render the given row into a line of text, using the given list of fields and collecting sums into sums.

get_status(**kw)

Extends lino.core.requests.ActorRequest.get_status().