Skip to content

Commit

Permalink
Removed the explicit set of NullCache if the Flask app is set testing…
Browse files Browse the repository at this point in the history
…=True
  • Loading branch information
thadeusb committed Aug 12, 2012
1 parent 53fb68e commit 9988abf
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions flaskext/cache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ def function_namespace(f):
class Cache(object):
"""
This class is used to control the cache objects.
If TESTING is True it will use NullCache.
"""

def __init__(self, app=None, with_jinja2_ext=True):
Expand Down Expand Up @@ -78,27 +76,24 @@ def init_app(self, app):
self._set_cache()

def _set_cache(self):
if self.app.config['TESTING']:
self.cache = NullCache()
else:
import_me = self.app.config['CACHE_TYPE']
if '.' not in import_me:
import_me = 'flaskext.cache.backends.' + \
import_me
import_me = self.app.config['CACHE_TYPE']
if '.' not in import_me:
import_me = 'flaskext.cache.backends.' + \
import_me

cache_obj = import_string(import_me)
cache_args = self.app.config['CACHE_ARGS'][:]
cache_options = dict(default_timeout= \
self.app.config['CACHE_DEFAULT_TIMEOUT'])
cache_obj = import_string(import_me)
cache_args = self.app.config['CACHE_ARGS'][:]
cache_options = dict(default_timeout= \
self.app.config['CACHE_DEFAULT_TIMEOUT'])

if self.app.config['CACHE_OPTIONS']:
cache_options.update(self.app.config['CACHE_OPTIONS'])
if self.app.config['CACHE_OPTIONS']:
cache_options.update(self.app.config['CACHE_OPTIONS'])

self.cache = cache_obj(self.app, cache_args, cache_options)
self.cache = cache_obj(self.app, cache_args, cache_options)

if not isinstance(self.cache, BaseCache):
raise TypeError("Cache object must subclass "
"werkzeug.contrib.cache.BaseCache")
if not isinstance(self.cache, BaseCache):
raise TypeError("Cache object must subclass "
"werkzeug.contrib.cache.BaseCache")

def get(self, *args, **kwargs):
"Proxy function for internal cache object."
Expand Down

2 comments on commit 9988abf

@tupy
Copy link
Contributor

@tupy tupy commented on 9988abf Jun 14, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @thadeusb, why did you removed this?

@thadeusb
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#23

Please sign in to comment.