Improve documentation

This commit adds a lot of documentation including block diagramms for
message flows.
This commit is contained in:
Jan Dittberner 2016-09-24 21:57:28 +02:00
parent 09cfc6a373
commit 5dc3549896
11 changed files with 853 additions and 87 deletions

View file

@ -1,6 +1,10 @@
"""
This module contains the signal handlers of the :py:mod:`userdbs` app.
The module starts Celery_ tasks.
.. _Celery: http://www.celeryproject.org/
"""
from __future__ import unicode_literals
@ -29,6 +33,34 @@ def handle_dbuser_password_set(sender, instance, password, **kwargs):
Signal handler triggered by password changes for
:py:class:`userdbs.models.DatabaseUser` instances.
:param sender: the sender of the signal
:param instance: the Database user instance
:param str password: the new password for the database user
This signal handler starts Celery_ tasks depending on the db_type value of
the database user.
.. blockdiag::
:desctable:
blockdiag {
node_width = 200;
A -> B;
A -> C;
A [ label = "", shape = beginpoint,
description = "this signal handler" ];
B [ label = "set mysql userpassword", color = "PowderBlue",
description = ":py:func:`set_mysql_userpassword()
<mysqltasks.tasks.set_mysql_userpassword>` called with
database username and password" ];
C [ label = "set pgsql userpassword", color = "DodgerBlue",
description = ":py:func:`set_pgsql_userpassword()
<pgsqltasks.tasks.set_pgsql_userpassword>` called with
database username and password" ];
}
"""
if instance.db_type == DB_TYPES.mysql:
taskresult = TaskResult.objects.create_task_result(
@ -59,6 +91,35 @@ def handle_dbuser_created(sender, instance, created, **kwargs):
Signal handler triggered after the creation of or updates to
:py:class:`userdbs.models.DatabaseUser` instances.
:param sender: the sender of the signal
:param instance: the DatabaseUser instance
:param bool created: whether this signal handler is called for a newly
created instance
This signal handler starts Celery_ tasks depending on the db_type value of
the database user.
.. blockdiag::
:desctable:
blockdiag {
node_width = 200;
A -> B;
A -> C;
A [ label = "", shape = beginpoint,
description = "this signal handler" ];
B [ label = "create mysql user", color = "PowderBlue",
description = ":py:func:`create_mysql_user()
<mysqltasks.tasks.create_mysql_user>` called with database
username and password" ];
C [ label = "create pgsql user", color = "DodgerBlue",
description = ":py:func:`create_pgsql_user
<pgsqltasks.tasks.create_pgsql_user>` called with database
username and password" ];
}
"""
if created:
password = kwargs.get('password', generate_password())
@ -95,6 +156,32 @@ def handle_dbuser_deleted(sender, instance, **kwargs):
Signal handler triggered after the deletion of
:py:class:`userdbs.models.DatabaseUser` instances.
:param sender: the sender of the signal
:param instance: the DatabaseUser instance
This signal handler starts Celery_ tasks depending on the db_type value of
the database user.
.. blockdiag::
:desctable:
blockdiag {
node_width = 200;
A -> B;
A -> C;
A [ label = "", shape = beginpoint,
description = "this signal handler" ];
B [ label = "delete mysql user", color = "PowderBlue",
description = ":py:func:`delete_mysql_user()
<mysqltasks.tasks.delete_mysql_user>` called with username
from instance.name" ];
C [ label = "delete pgsql user", color = "DodgerBlue",
description = ":py:func:`delete_pgsql_user()
<pgsqltasks.tasks.delete_pgsql_user>` called with username
from instance.name" ];
}
"""
if instance.db_type == DB_TYPES.mysql:
taskresult = TaskResult.objects.create_task_result(
@ -126,6 +213,34 @@ def handle_userdb_created(sender, instance, created, **kwargs):
Signal handler triggered after the creation of or updates to
:py:class:`userdbs.models.UserDatabase` instances.
:param sender: the sender of the signal
:param instance: the UserDatabase instance
:param bool created: whether this signal handler has been called for a
newly created instance
This signal handler starts Celery_ tasks depending on the db_type value of
the database user owning the UserDatabase instance.
.. blockdiag::
:desctable:
blockdiag {
node_width = 200;
A -> B;
A -> C;
A [ label = "", shape = beginpoint,
description = "this signal handler" ];
B [ label = "create mysql database", color = "PowderBlue",
description = ":py:func:`create_mysql_database()
<mysqltasks.tasks.create_mysql_database>` called with database
name and username" ];
C [ label = "create pgsql database", color = "DodgerBlue",
description = ":py:func:`create_pgsql_database()
<pgsqltasks.tasks.create_pgsql_database>` called with database
name and username" ];
}
"""
if created:
if instance.db_user.db_type == DB_TYPES.mysql:
@ -163,6 +278,32 @@ def handle_userdb_deleted(sender, instance, **kwargs):
Signal handler triggered after the deletion of
:py:class:`userdbs.models.UserDatabase` instances.
:param sender: the sender of the signal
:param instance: the UserDatabase instance
This signal handler starts Celery_ tasks depending on the db_type value of
the database user owning the UserDatabase instance.
.. blockdiag::
:desctable:
blockdiag {
node_width = 200;
A -> B;
A -> C;
A [ label = "", shape = beginpoint,
description = "this signal handler" ];
B [ label = "delete mysql database", color = "PowderBlue",
description = ":py:func:`delete_mysql_user()
<mysqltasks.tasks.delete_mysql_user>` called with database
name and username" ];
C [ label = "delete pgsql database", color = "DodgerBlue",
description = ":py:func:`delete_pgsql_user()
<pgsqltasks.tasks.delete_pgsql_user>` called with database
name" ];
}
"""
if instance.db_user.db_type == DB_TYPES.mysql:
taskresult = TaskResult.objects.create_task_result(