From 83bad3d88d24d53de7efeca645c7287cf3127a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 26 Jul 2016 17:20:03 +0200 Subject: [PATCH] Don't fetch entire project just to fetch a node type. The query can probably be made more specific by including the node type beforehand, and only fetching that. --- pillar/application/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pillar/application/__init__.py b/pillar/application/__init__.py index 0ff5071d..ed3c01ca 100644 --- a/pillar/application/__init__.py +++ b/pillar/application/__init__.py @@ -54,10 +54,13 @@ class ValidateCustomFields(Validator): projects_collection = app.data.driver.db['projects'] lookup = {'_id': ObjectId(self.document['project'])} - project = projects_collection.find_one(lookup) + project = projects_collection.find_one(lookup, { + 'node_types.name': 1, + 'node_types.dyn_schema': 1, + }) if project is None: log.warning('Unknown project %s, declared by node %s', - project, self.document.get('_id')) + lookup, self.document.get('_id')) self._error(field, 'Unknown project') return False