web

AioHTTP Web Server Setup

Functions

handle_errors(request, handler)

jinja2_filter_markdown(text)

jinja_defaults(request)

Provides all web views using aiohttp-jinja2 with default values

start()

Initialize App

start_with_celery()

Initialize app and launch internal celery worker

Classes

AuthorizationPolicy(app)

Authorization policy for web interface

Documentation

class bioconda_utils.bot.web.AuthorizationPolicy(app)[source]

Bases: aiohttp_security.abc.AbstractAuthorizationPolicy

Authorization policy for web interface

async authorized_userid(identity)[source]

Retrieve authorized user id.

Parameters

identity (str) – random string identifying user. We use bearer token.

Return type

AiohttpGitHubHandler

Returns

Logged in Github API client.

async permits(identity, permission, context=None)[source]

Check user permissions.

Return type

bool

Returns

True if the identity is allowed the permission in the current context.

bioconda_utils.bot.web.LOGLEVEL = 'INFO'

Override this to get more verbose logging of web app (and, if launched with web frontend, the worker).

async bioconda_utils.bot.web.jinja_defaults(request)[source]

Provides all web views using aiohttp-jinja2 with default values

Values are:
  • user: The `AiohttpGitHubHandler for the user if a user is logged in.

  • version: The version of the bot running

  • navigation_bar: List of 3-tuples for building nav bar. Each tuple comprises the location, ID and natural name for the page to be added to the main nav bar.

  • active_page: The ID of the currently rendered page. This is set in the aiohttp router as name field.

  • title: The title of the current page. Parsed from navigation_bar using active_page.

async bioconda_utils.bot.web.start()[source]

Initialize App

This function is the entry point for wrappers that take an app factory as argument, notably gunicorn:

$ gunicorn bioconda_utils.bot:init_app –worker-class aiohttp.worker.GunicornWebWorker –reload

async bioconda_utils.bot.web.start_with_celery()[source]

Initialize app and launch internal celery worker

This isn’t simply a flag for start because async app factories cannot (easily) receive parameters from the gunicorn commandline.