adhocracy_core.websockets.client module

Our own Websocket client that notifies the server of changes.

class Client(ws_url)[source]

Bases: object

Websocket Client.

Create instance with running thread that talks to the server.

Parameters:ws_url – the URL of the websocket server to connect to; if None, no connection will be set up (useful for testing)
changelog_metadata_messages_to_send = None

Set with adhocracy_core.resources.subscriber.ChangelogMetadata that will be send to the websocket server with Client.send_messages().

send_messages(changelog_metadata=[])[source]

Send all changelog messages to the websocket server.

Parameters:changelog_metadata – list of :class:’ChangelogMetadata’, metadata.resource == None is ignored.

All websocket exceptions are catched, hoping the problems will be solved when you run this method again.

stop()[source]

Stop the client.

get_ws_client(registry) → adhocracy_core.websockets.client.Client[source]

Return websocket client object or None.

send_messages_after_commit_hook(success, registry)[source]

Send transaction changelog messages to the websocket client.

includeme(config)[source]

Add websocket client (ws_client) to the registry.

You need to set the ws server url in your settings to make this work:

adhocracy.ws_url =  ws://localhost:6561