gs.group.topic.digest.send code

The code for the script that sends out the digest works in two main stages: first it gets the list of groups, and then it sends a digest. Both raise the same exceptions.

The list of groups

The list of groups is retrieved using a web-hook that returns a list of groups as a JSON blob. The DIGEST_GROUPS_URI specifies the location of the web-hook, relative to the root of the site, while the get_digest_groups() function retrieves the list of groups.

gs.group.messages.topic.digest.send.script.DIGEST_GROUPS_URI = u'/gs-group-messages-topic-digest-groups.html'

The URL of the web-hook that returns (as a JSON blob) the list of groups that need a digest.

gs.group.messages.topic.digest.send.script.get_digest_groups(hostname, token)[source]

Get the list of groups to send the digest to.

Parameters:
  • hostname (str) – The name of the host to use.
  • token (str) – The token to use for authentication.
Raises:

NotOk – When the page does not return an HTTP 200 status code.

Returns:

A list of 2-tuples (siteId, groupId), sorted alphabetically

Return type:

tuple

Sending a digest

The digest is actually send by a web-hook. This hook is located at SEND_DIGEST_URI and is triggered by the send_digest() function.

gs.group.messages.topic.digest.send.script.SEND_DIGEST_URI = u'/gs-group-messages-topic-digest-send.html'

The URL of the web-hook used to send a digest to a group

gs.group.messages.topic.digest.send.script.send_digest(hostname, siteId, groupId, token)[source]

Send a digest for a particular group

Parameters:
  • hostname (str) – The name of the host to use.
  • siteId (str) – The identifier for the site that contains the group.
  • groupId (str) – The identifier for the group.
  • token (str) – The token to use for authentication.
Raises:

NotOk – When the page does not return an HTTP 200 status code.

Exceptions

class gs.group.messages.topic.digest.send.script.NotOk[source]

Raised when a web-hook does not return a 200 status code