From 3b6fa6ef27cbc7c84819375ffa2839feb3d98e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 26 Jul 2016 13:36:59 +0200 Subject: [PATCH] Slight code optimisation --- pillar/application/modules/nodes.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pillar/application/modules/nodes.py b/pillar/application/modules/nodes.py index a347fc84..7212b62a 100644 --- a/pillar/application/modules/nodes.py +++ b/pillar/application/modules/nodes.py @@ -139,11 +139,12 @@ def item_parse_attachments(response): generated link. """ - if 'properties' not in response or 'attachments' not in response['properties']: + attachments = response.get('properties', {}).get('attachments', None) + if not attachments: return files_collection = current_app.data.driver.db['files'] - for attachment in response['properties']['attachments']: + for attachment in attachments: # Make a list from the property path field_name_path = attachment['field'].split('.') # This currently allow to access only properties inside of