Skip to content

Commit

Permalink
Fix AttributeErrors from missing config sections
Browse files Browse the repository at this point in the history
  • Loading branch information
clenk committed Apr 6, 2024
1 parent fa55e55 commit 0c9ec71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions medallion/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from six import iteritems

APPLICATION_INSTANCE = Flask("medallion")
APPLICATION_INSTANCE.taxii_config = {}
APPLICATION_INSTANCE.usersconfig = {}
APPLICATION_INSTANCE.backend_config = {}


def create_resource(resource_name, items, more=False, next_id=None):
Expand Down Expand Up @@ -276,16 +279,16 @@ def start(self):
def get_application_instance_config_values(flask_application_instance, config_group, config_key=None):
if config_group == "taxii":
if flask_application_instance.taxii_config and config_key in flask_application_instance.taxii_config:
return flask_application_instance.taxii_config[config_key]
return flask_application_instance.taxii_config.get(config_key)
else:
return flask_application_instance.taxii_config
if config_group == "users":
if flask_application_instance.users_config and config_key in flask_application_instance.users_config:
return flask_application_instance.users_config[config_key]
return flask_application_instance.users_config.get(config_key)
else:
return flask_application_instance.users_config
if config_group == "backend":
if flask_application_instance.backend_config and config_key in flask_application_instance.backend_config:
return flask_application_instance.backend_config[config_key]
return flask_application_instance.backend_config.get(config_key)
else:
return flask_application_instance.backend_config
2 changes: 1 addition & 1 deletion medallion/views/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def validate_version_parameter_in_content_type_header():


def validate_limit_parameter():
max_page = current_app.taxii_config["max_page_size"]
max_page = current_app.taxii_config.get("max_page_size")
limit = request.args.get("limit", max_page)
try:
limit = int(limit)
Expand Down

0 comments on commit 0c9ec71

Please sign in to comment.