From eca6c283363f0ae8d35459c8e78ad96211df7884 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Fri, 28 Sep 2012 09:20:21 +0100 Subject: [PATCH] Better checks: in debug mode only a critical exception if write permissions on read-only db. --- ckanext/datastore/plugin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ckanext/datastore/plugin.py b/ckanext/datastore/plugin.py index 510885f54c0..e4a30f82445 100644 --- a/ckanext/datastore/plugin.py +++ b/ckanext/datastore/plugin.py @@ -51,7 +51,7 @@ def configure(self, config): # so that no harmful queries can be made if not ('debug' in config and config['debug']): self._check_separate_db() - self._check_read_permissions() + self._check_read_permissions() self._create_alias_table() else: @@ -155,7 +155,10 @@ def _check_read_permissions(self): raise else: log.info("Connection url {0}".format(self.read_url)) - raise Exception("We have write permissions on the read-only database.") + if 'debug' in self.config and self.config['debug']: + log.critical("We have write permissions on the read-only database.") + else: + raise Exception("We have write permissions on the read-only database.") finally: read_trans.rollback() except Exception: