swpt_lib.endpoints

Build and match URLs to endpoints.

The available endpoints are:

authority
/authority
debtor
/debtors/<i64:debtorId>/
creditor
/creditors/<i64:creditorId>/
account
/creditors/<i64:creditorId>/debtors/<i64:debtorId>
exception swpt_lib.endpoints.BuildError

An URL can not be build for the endpoint.

exception swpt_lib.endpoints.MatchError

The URL does not match the endpoint.

swpt_lib.endpoints.build_url(endpoint, **kw)

Try to build an absolute URL for a given endpoint and arguments.

Parameters:
  • endpoint (str) – The name of the endpoint
  • kw – The keyword arguments required by the particular endpoint
Returns:

The absolute URL

Raises BuildError if an URL can not be build for the endpoint.

swpt_lib.endpoints.get_server_name()

Return site’s domain name (and maybe port), or None if not set.

The site’s domain name and port can be configured by setting the SWPT_SERVER_NAME environment variable.

swpt_lib.endpoints.get_url_scheme()

Return site’s URL scheme, or “http” if not set.

The site’s URL scheme can be configured by setting the SWPT_URL_SCHEME environment variable.

swpt_lib.endpoints.match_url(endpoint, url)

Try to to match an absolute URL to given endpoint.

Parameters:
  • endpoint (str) – The name of the endpoint
  • url (str) – The absolute URL that should be matched
Returns:

A dict of arguments extracted from the URL

Raises MatchError if the URL does not match the endpoint.