Source code for wuttamess.wutta

# -*- coding: utf-8; -*-
################################################################################
#
#  WuttaMess -- Fabric Automation Helpers
#  Copyright © 2024-2025 Lance Edgar
#
#  This file is part of Wutta Framework.
#
#  Wutta Framework is free software: you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the Free
#  Software Foundation, either version 3 of the License, or (at your option) any
#  later version.
#
#  Wutta Framework is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
#  more details.
#
#  You should have received a copy of the GNU General Public License along with
#  Wutta Framework.  If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
"""
Utilities for Wutta Framework
"""

from wuttamess import postgres


[docs] def purge_email_settings(c, dbname, appname="wutta"): """ Purge production email settings for a database. This can be used when cloning a production app DB to a test server. The general pattern is: * setup test app on test server * config file should specify test email settings * clone the production DB to test server * call this function to purge email settings from test DB So the end result should be, the test server app can run and send emails safely using only what is specified in config file(s), since none of the production email settings remain in the test DB. :param dbname: Name of the database to be updated. :param appname: The ``appname`` used to determine setting names. """ postgres.sql( c, f"delete from setting where name like '{appname}.email.%.sender';", database=dbname, ) postgres.sql( c, f"delete from setting where name like '{appname}.email.%.to';", database=dbname, ) postgres.sql( c, f"delete from setting where name like '{appname}.email.%.cc';", database=dbname, ) postgres.sql( c, f"delete from setting where name like '{appname}.email.%.bcc';", database=dbname, )