sextile.handlers

The framework’s own pages as handlers, and one call to route them all.

The pure page builders are in sextile.builtin, taking exactly what they draw. The functions here gather what each needs from request.app – the route’s title, how to label a visited address, the service’s index – and are the (request) -> Page handlers a service routes. Registered nowhere: a service maps each into its own numbering or does without.

guide_page is called directly, because the rows it adds are the service’s own. The rest are routed through standard_pages, which returns the routes for whichever of these a service gives a number, each carrying the framework’s own title, detail and keywords, so a service names the page once and retypes nothing:

Sextile(pages=[*my_pages, *standard_pages(history="92", contents="93", keywords="94")])

The readership pages – what has been read lately, most, and how many have called – read the service’s own visit log, so they are given the StateKey the log is held under, the same key a service hands record_visits.

sextile.handlers.callers(visits)[source]

A handler for how many have called, reading visits from the log.

Parameters:

visits (StateKey[Visits])

Return type:

Handler

async sextile.handlers.callers_page(request, visits, *, periods=((datetime.timedelta(days=1), 'Last 24 hours'), (datetime.timedelta(days=7), 'Last 7 days'), (datetime.timedelta(days=30), 'Last 30 days')))[source]

How many have called, over each of a few periods.

A count of connections rather than of anybody. periods is the service’s to choose; a period longer than the log’s retention simply reads low.

Parameters:
Return type:

Page

async sextile.handlers.contents(request)[source]

Every page the service advertises, at the service’s own number.

Parameters:

request (PageRequest)

Return type:

Page

async sextile.handlers.contents_page(request)[source]

Every page this service advertises, with the number that fetches it.

Pages with fields are listed as *52<user_id># rather than enumerated: nobody can list every user on a screen, and everybody holding a user number can be told where to put it.

Parameters:

request (PageRequest)

Return type:

Page

async sextile.handlers.guide_page(request, *, moving_rows=(), asking_rows=(), show_item_keys=True)[source]

How to get about, as a table of the keys this service answers.

The framework’s own keys – the digits, the way home, the syntax of a request, the key that turns a page – are drawn from what it already knows. A service adds through moving_rows and asking_rows the rows only it can supply: the keys a particular page answers, such as a letter typed into a field, or a single key such as F.

Parameters:
  • request (PageRequest) – The request this page answers.

  • moving_rows (Sequence[GuideRow]) – The service’s own rows about moving about, joining the first frame after the framework’s.

  • asking_rows (Sequence[GuideRow]) – The service’s own rows about asking for something, joining the second frame.

  • show_item_keys (bool) – Whether the compass shows A and D. False for a service that does not wire them to request.neighbours and so does not answer them.

Return type:

Page

Returns:

The guide, as two frames of keys.

async sextile.handlers.history(request)[source]

Where this caller has been, at whatever number the service gives it.

Parameters:

request (PageRequest)

Return type:

Page

async sextile.handlers.history_page(request)[source]

Where this caller has been, newest first, as a menu of shortcuts.

Key 1 for the page before this one – the same as *0# – 2 for the one before that, and so on. Registered nowhere: a service maps it into its own numbering with standard_pages, or does not offer it at all.

Parameters:

request (PageRequest)

Return type:

Page

async sextile.handlers.keywords(request)[source]

The words a reader can key, at the service’s own number.

Parameters:

request (PageRequest)

Return type:

Page

async sextile.handlers.keywords_page(request)[source]

The words a reader can key in place of a page number.

Generated from the service’s keywords, so it cannot drift from what the service answers.

Parameters:

request (PageRequest)

Return type:

Page

sextile.handlers.popular(visits)[source]

A handler for the pages looked at most, reading visits from the log.

Parameters:

visits (StateKey[Visits])

Return type:

Handler

async sextile.handlers.popular_page(request, visits, *, limit=9, prefix='', since=None)[source]

What has been looked at most, as a menu of where to look.

Parameters:
  • request (PageRequest) – The request this page answers.

  • visits (Visits) – The log to read.

  • limit (int) – How many to show, defaulting to the nine a frame holds. More than that runs on to further frames.

  • prefix (str) – Narrows it to a namespace of the numbering.

  • since (datetime | None) – Counts only what has been read since then, for “most read lately” rather than most read ever.

Return type:

Page

Returns:

A menu of the pages looked at most, the most read first.

sextile.handlers.recent(visits)[source]

A handler for the pages looked at lately, reading visits from the log.

Parameters:

visits (StateKey[Visits])

Return type:

Handler

async sextile.handlers.recent_page(request, visits, *, limit=9, prefix='')[source]

What has been looked at lately, as a menu of where to look.

Parameters:
  • request (PageRequest) – The request this page answers.

  • visits (Visits) – The log to read.

  • limit (int) – How many to show, defaulting to the nine a frame holds. More than that runs on to further frames.

  • prefix (str) – Narrows it to a namespace of the numbering, so a service can ask for one namespace’s pages alone.

Return type:

Page

Returns:

A menu of the pages looked at lately, newest first.

sextile.handlers.standard_pages(*, history=None, contents=None, keywords=None, recent=None, popular=None, callers=None, visits=None)[source]

Routes for the framework’s own pages, at whatever numbers a service gives.

Each argument is the page number to route that page at, or None to leave it out. The route carries the framework’s own title, detail and keywords, so a service names the page once, by its number, and retypes nothing.

Parameters:
  • history (str | None) – Where the caller has been this call.

  • contents (str | None) – Every page the service advertises.

  • keywords (str | None) – The words a reader can key in place of a number.

  • recent (str | None) – What has been looked at lately.

  • popular (str | None) – What has been looked at most.

  • callers (str | None) – How many have called.

  • visits (Optional[StateKey[Visits]]) – The StateKey the visit log is held under, which recent, popular and callers read; the same key a service hands record_visits.

Return type:

tuple[PageRoute, ...]

Returns:

A PageRoute for each page given a number, in the order named above.

Raises:

ValueError – If recent, popular or callers is given without visits to read the log from.