diff --git a/spiffworkflow-backend/bin/codemod/update_file_to_remove_function.py b/spiffworkflow-backend/bin/codemod/update_file_to_remove_function.py index 82d571fa9..bc975c7c5 100644 --- a/spiffworkflow-backend/bin/codemod/update_file_to_remove_function.py +++ b/spiffworkflow-backend/bin/codemod/update_file_to_remove_function.py @@ -1,19 +1,23 @@ +"""This is used by bin/codemod/remove_all_unused_functions to remove a function from a file.""" from bowler import Query -from bowler.types import Leaf # This came about because vulture (actually dead, from the list of Similar programs at https://pypi.org/project/vulture/) # actually found unused stuff, and I wanted to remove it. # See also https://github.com/craigds/decrapify + def remove_function(filename: str, function_name: str) -> None: + """Does the dirty work of actually removing the function from the file in place, or failing if it cannot.""" def remove_statement(node, capture, filename): node.remove() - bowler_query = (Query(filename) + bowler_query = ( + Query(filename) .select_function(function_name) .modify(remove_statement) - .execute(write=True, silent=True, interactive=False)) + .execute(write=True, silent=True, interactive=False) + ) if len(bowler_query.exceptions) > 0: print(f"Failed to remove function {function_name} from {filename}.") diff --git a/spiffworkflow-backend/bin/import_tickets_for_command_line.py b/spiffworkflow-backend/bin/import_tickets_for_command_line.py index 1392c1118..0780f2097 100644 --- a/spiffworkflow-backend/bin/import_tickets_for_command_line.py +++ b/spiffworkflow-backend/bin/import_tickets_for_command_line.py @@ -11,6 +11,8 @@ from spiffworkflow_backend.services.process_instance_processor import ( from spiffworkflow_backend.services.process_instance_service import ( ProcessInstanceService, ) + + def main(): """Main.""" app = get_hacked_up_app_for_script() diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py b/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py index 8c308e03f..addab68fc 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py @@ -153,3 +153,9 @@ SPIFFWORKFLOW_BACKEND_FEATURE_ELEMENT_UNITS_ENABLED = ( SPIFFWORKFLOW_BACKEND_ELEMENT_UNITS_CACHE_DIR = environ.get( "SPIFFWORKFLOW_BACKEND_ELEMENT_UNITS_CACHE_DIR", default=None ) + +# adds the ProxyFix to Flask on http by processing the 'X-Forwarded-Proto' header +# to make SpiffWorkflow aware that it should return https for the server urls etc rather than http. +SPIFFWORKFLOW_BACKEND_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX = ( + environ.get("SPIFFWORKFLOW_BACKEND_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX", default="false") == "true" +) diff --git a/spiffworkflow-backend/wsgi.py b/spiffworkflow-backend/wsgi.py index 7d9d954d8..f2d6d87d7 100644 --- a/spiffworkflow-backend/wsgi.py +++ b/spiffworkflow-backend/wsgi.py @@ -7,8 +7,10 @@ from spiffworkflow_backend.services.acceptance_test_fixtures import ( ) app = create_app() -if os.environ.get("SPIFFWORKFLOW_BACKEND_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX") == "true": + +if app.config["SPIFFWORKFLOW_BACKEND_USE_WERKZEUG_MIDDLEWARE_PROXY_FIX"]: from werkzeug.middleware.proxy_fix import ProxyFix + app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1) # this is in here because when we put it in the create_app function,