Compatibility with Eve 0.9.1

Note that Eve's update from 0.9 → 0.9.1 had a breaking API change, as the
return type of `app.data.find(...)` changed...
This commit is contained in:
2019-05-29 10:50:55 +02:00
parent 459a579964
commit dd5cd5b61a
2 changed files with 5 additions and 4 deletions

View File

@@ -470,7 +470,7 @@ def before_returning_files(response):
ensure_valid_link(item) ensure_valid_link(item)
def ensure_valid_link(response): def ensure_valid_link(response: dict) -> None:
"""Ensures the file item has valid file links using generate_link(...).""" """Ensures the file item has valid file links using generate_link(...)."""
# Log to function-specific logger, so we can easily turn it off. # Log to function-specific logger, so we can easily turn it off.
@@ -495,12 +495,13 @@ def ensure_valid_link(response):
generate_all_links(response, now) generate_all_links(response, now)
def generate_all_links(response, now): def generate_all_links(response: dict, now: datetime.datetime) -> None:
"""Generate a new link for the file and all its variations. """Generate a new link for the file and all its variations.
:param response: the file document that should be updated. :param response: the file document that should be updated.
:param now: datetime that reflects 'now', for consistent expiry generation. :param now: datetime that reflects 'now', for consistent expiry generation.
""" """
assert isinstance(response, dict), f'response must be dict, is {response!r}'
project_id = str( project_id = str(
response['project']) if 'project' in response else None response['project']) if 'project' in response else None
@@ -565,7 +566,7 @@ def on_pre_get_files(_, lookup):
lookup_expired = lookup.copy() lookup_expired = lookup.copy()
lookup_expired['link_expires'] = {'$lte': now} lookup_expired['link_expires'] = {'$lte': now}
cursor = current_app.data.find('files', parsed_req, lookup_expired) cursor, _ = current_app.data.find('files', parsed_req, lookup_expired, perform_count=False)
for idx, file_doc in enumerate(cursor): for idx, file_doc in enumerate(cursor):
if idx == 0: if idx == 0:
log.debug('Updating expired links for files that matched lookup %s', lookup_expired) log.debug('Updating expired links for files that matched lookup %s', lookup_expired)

View File

@@ -28,7 +28,7 @@ commonmark = "~0.9"
elasticsearch = "~6.1" elasticsearch = "~6.1"
elasticsearch-dsl = "~6.1" elasticsearch-dsl = "~6.1"
Eve = "~0.8" # currently latest is 0.9 Eve = "~0.9"
Flask = "~1.0" Flask = "~1.0"
Flask-Babel = "~0.12" Flask-Babel = "~0.12"
Flask-Caching = "~1.7" Flask-Caching = "~1.7"