Storage backends — Sphinx documentation (original) (raw)

To create a custom storage backend you will need to subclass theStorageBackend class. Then create an instance of the new class and pass that as the storage keyword argument when you create theWebSupport object:

support = WebSupport(srcdir=srcdir, builddir=builddir, storage=MyStorage())

For more information about creating a custom storage backend, please see the documentation of the StorageBackend class below.

class sphinxcontrib.websupport.storage.StorageBackend[source]

Defines an interface for storage backends.

Changed in version 1.6: StorageBackend class is moved to sphinxcontrib.websupport.storage from sphinx.websupport.storage.

Methods

StorageBackend.pre_build()[source]

Called immediately before the build process begins. Use this to prepare the StorageBackend for the addition of nodes.

StorageBackend.add_node(id, document, source)[source]

Add a node to the StorageBackend.

Parameters:

StorageBackend.post_build()[source]

Called after a build has completed. Use this to finalize the addition of nodes if needed.

Called when a comment is being added.

Parameters:

Delete a comment.

Raises UserNotAuthorizedErrorif moderator is False and username doesn’t match the username on the comment.

Parameters:

StorageBackend.get_data(node_id, username, moderator)[source]

Called to retrieve all data for a node. This should return a dict with two keys, source and comments as described byWebSupport’sget_data() method.

Parameters:

StorageBackend.process_vote(comment_id, username, value)[source]

Process a vote that is being cast. value will be either -1, 0, or 1.

Parameters:

StorageBackend.update_username(old_username, new_username)[source]

If a user is allowed to change their username this method should be called so that there is not stagnate data in the storage system.

Parameters:

Called when a moderator accepts a comment. After the method is called the comment should be displayed to all users.

Parameters:

comment_id – The id of the comment being accepted.