ストレージバックエンド¶
カスタムのストレージバックエンドを作るには、 StorageBackend
クラスのサブクラスを作ります。その後、新しいクラスのインスタンスを作成し、 WebSupport
オブジェクトのを作る時に、 storage キーワード引数で渡します:
support = WebSupport(srcdir=srcdir,
builddir=builddir,
storage=MyStorage())
カスタムのストレージバックエンドを作る際のより詳しい情報は、これから説明する StorageBackend
クラスのドキュメントを参照してください。
バージョン 1.6 で変更: StorageBackend クラスは sphinx.websupport.storage からsphinxcontrib.websupport.storage へ移動しました。
メソッド¶
-
StorageBackend.
pre_build
()[ソース]¶ Called immediately before the build process begins. Use this to prepare the StorageBackend for the addition of nodes.
-
StorageBackend.
add_node
(id, document, source)[ソース]¶ Add a node to the StorageBackend.
- パラメータ
id -- a unique id for the comment.
document -- the name of the document the node belongs to.
source -- the source files name.
-
StorageBackend.
post_build
()[ソース]¶ Called after a build has completed. Use this to finalize the addition of nodes if needed.
-
StorageBackend.
add_comment
(text, displayed, username, time, proposal, node_id, parent_id, moderator)[ソース]¶ Called when a comment is being added.
- パラメータ
text -- the text of the comment
displayed -- whether the comment should be displayed
username -- the name of the user adding the comment
time -- a date object with the time the comment was added
proposal -- the text of the proposal the user made
node_id -- the id of the node that the comment is being added to
parent_id -- the id of the comment's parent comment.
moderator -- whether the user adding the comment is a moderator
-
StorageBackend.
delete_comment
(comment_id, username, moderator)[ソース]¶ Delete a comment.
Raises
UserNotAuthorizedError
if moderator is False and username doesn't match the username on the comment.- パラメータ
comment_id -- The id of the comment being deleted.
username -- The username of the user requesting the deletion.
moderator -- Whether the user is a moderator.
-
StorageBackend.
get_data
(node_id, username, moderator)[ソース]¶ Called to retrieve all data for a node. This should return a dict with two keys, source and comments as described by
WebSupport
'sget_data()
method.- パラメータ
node_id -- The id of the node to get data for.
username -- The name of the user requesting the data.
moderator -- Whether the requestor is a moderator.
-
StorageBackend.
process_vote
(comment_id, username, value)[ソース]¶ Process a vote that is being cast. value will be either -1, 0, or 1.
- パラメータ
comment_id -- The id of the comment being voted on.
username -- The username of the user casting the vote.
value -- The value of the vote being cast.
-
StorageBackend.
update_username
(old_username, new_username)[ソース]¶ 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.
- パラメータ
old_username -- The username being changed.
new_username -- What the username is being changed to.