From a100d73a8b95886673740810df73661a0d05b89b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 14 Dec 2016 11:26:28 +0100 Subject: [PATCH] Collections in extension eve_settings now should start with the ext name. Instead of Pillar automagically prepending 'attract.' or 'flamenco.' to the names this should now be done explicitly in the extension's Eve settings. This allows for more explicit configuration, and ensures foreign key definitions are unambiguous. --- pillar/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pillar/__init__.py b/pillar/__init__.py index 5ecd00bf..22a3a4b2 100644 --- a/pillar/__init__.py +++ b/pillar/__init__.py @@ -225,11 +225,14 @@ class PillarServer(Eve): eve_settings = pillar_extension.eve_settings() if 'DOMAIN' in eve_settings: + pillar_ext_prefix = pillar_extension.name + '.' for key, collection in eve_settings['DOMAIN'].items(): - source = '%s.%s' % (pillar_extension.name, key) - url = '%s/%s' % (pillar_extension.name, key) + assert key.startswith(pillar_ext_prefix), \ + 'Eve collection names of %s MUST start with %r' % \ + (pillar_extension.name, pillar_ext_prefix) + url = key.replace('.', '/') - collection.setdefault('datasource', {}).setdefault('source', source) + collection.setdefault('datasource', {}).setdefault('source', key) collection.setdefault('url', url) self.config['DOMAIN'].update(eve_settings['DOMAIN'])