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
This commit is contained in:
David Stanek 2014-03-31 00:26:17 +00:00
parent b23951b5a0
commit f9c5d75654
2 changed files with 2 additions and 2 deletions

View File

@ -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.

View File

@ -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