Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions opentaxii/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class ServerConfig(dict):
"title",
"public_discovery",
"allow_custom_properties",
"max_pagination_limit",
"default_pagination_limit"
)
ALL_VALID_OPTIONS = VALID_BASE_OPTIONS + VALID_TAXII_OPTIONS + VALID_TAXII1_OPTIONS

Expand Down
2 changes: 2 additions & 0 deletions opentaxii/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ taxii1:
create_tables: yes

taxii2:
default_pagination_limit: 10
max_pagination_limit: 1000

logging:
opentaxii: info
Expand Down
2 changes: 2 additions & 0 deletions opentaxii/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ def collection_handler(self, api_root_id, collection_id_or_alias):
)
def manifest_handler(self, api_root_id, collection_id_or_alias):
filter_params = validate_list_filter_params(request.args, self.persistence.api)
filter_params["limit"] = self.config.get("max_pagination_limit") if filter_params.get("limit", self.config.get("max_pagination_limit")) > self.config.get("max_pagination_limit") else filter_params.get("limit", self.config.get("default_pagination_limit"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a single line, this is not very readable and probably not compatible with the linter.

Also, it is used multiple times, you may move it to a dedicated method.

try:
manifest, more = self.persistence.get_manifest(
api_root_id=api_root_id,
Expand Down Expand Up @@ -652,6 +653,7 @@ def objects_handler(self, api_root_id, collection_id_or_alias):

def objects_get_handler(self, api_root_id, collection_id_or_alias):
filter_params = validate_list_filter_params(request.args, self.persistence.api)
filter_params["limit"] = self.config.get("max_pagination_limit") if filter_params.get("limit", self.config.get("max_pagination_limit")) > self.config.get("max_pagination_limit") else filter_params.get("limit", self.config.get("default_pagination_limit"))
try:
objects, more, next_param = self.persistence.get_objects(
api_root_id=api_root_id,
Expand Down