Skip to content

Commit

Permalink
Deletion handlers: Make protocol implementation explicit; tweak handl…
Browse files Browse the repository at this point in the history
…er check.
  • Loading branch information
liffiton committed Dec 12, 2024
1 parent 05d7286 commit 7d44379
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/codehelp/deletion_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

"""Implementation of personal data deletion for CodeHelp."""

from gened.data_deletion import register_handler
from gened.data_deletion import DeletionHandler, register_handler
from gened.db import get_db


class CodeHelpDeletionHandler:
class CodeHelpDeletionHandler(DeletionHandler):
"""CodeHelp implementation of personal data deletion."""

def delete_user_data(self, user_id: int) -> None:
Expand Down
2 changes: 1 addition & 1 deletion src/gened/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def create_app_base(import_name: str, app_config: dict[str, Any], instance_path:
app.config.from_mapping(total_config)

# verify deletion handler is registered
if data_deletion.get_handler() is None:
if not data_deletion.has_handler():
app.logger.error("No deletion handler registered. All Gen-Ed applications must provide one.")
sys.exit(1)

Expand Down
6 changes: 3 additions & 3 deletions src/gened/data_deletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def register_handler(handler: DeletionHandler) -> None:
_handler = handler


def get_handler() -> DeletionHandler | None:
"""Get the registered deletion handler."""
return _handler
def has_handler() -> bool:
"""Return whether a deletion handler has been registered (True) or not (False)."""
return _handler is not None


def delete_user_data(user_id: int) -> None:
Expand Down
4 changes: 2 additions & 2 deletions src/starburst/deletion_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#
# SPDX-License-Identifier: AGPL-3.0-only

from gened.data_deletion import register_handler
from gened.data_deletion import DeletionHandler, register_handler
from gened.db import get_db


class StarburstDeletionHandler:
class StarburstDeletionHandler(DeletionHandler):
"""Handler for deleting Starburst user data."""

def delete_user_data(self, user_id: int) -> None:
Expand Down

0 comments on commit 7d44379

Please sign in to comment.