From f9c5d756549aa5352cf3289897439426ecfcf779 Mon Sep 17 00:00:00 2001 From: David Stanek Date: Mon, 31 Mar 2014 00:26:17 +0000 Subject: [PATCH] Fix cache configuration checks There were two different checks to see if a cache region was already configured with a backend. Both were changed to use the Region.is_configured property. The initial reason for this change was that the hasattr approach in the test fixture was causing some issues in Python 3. For some reason it was forcing the __get__ lookup on the descriptor and Python 2 did not. bp python3 Change-Id: I409656f5ede08160cc68d48e7a3a636328e3e9a6 --- keystone/common/cache/core.py | 2 +- keystone/tests/ksfixtures/cache.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/keystone/common/cache/core.py b/keystone/common/cache/core.py index f66b7037bd..7703652f6f 100644 --- a/keystone/common/cache/core.py +++ b/keystone/common/cache/core.py @@ -118,7 +118,7 @@ def configure_cache_region(region): raise exception.ValidationError( _('region not type dogpile.cache.CacheRegion')) - if 'backend' not in region.__dict__: + if not region.is_configured: # NOTE(morganfainberg): this is how you tell if a region is configured. # There is a request logged with dogpile.cache upstream to make this # easier / less ugly. diff --git a/keystone/tests/ksfixtures/cache.py b/keystone/tests/ksfixtures/cache.py index cb5f126929..74566f1ebc 100644 --- a/keystone/tests/ksfixtures/cache.py +++ b/keystone/tests/ksfixtures/cache.py @@ -29,7 +29,7 @@ class Cache(fixtures.Fixture): # NOTE(morganfainberg): The only way to reconfigure the CacheRegion # object on each setUp() call is to remove the .backend property. - if hasattr(cache.REGION, 'backend'): + if cache.REGION.is_configured: del cache.REGION.backend # ensure the cache region instance is setup