Skip to content

Commit

Permalink
core.utils deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
nitely committed May 19, 2016
1 parent a975b43 commit 2144f32
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
22 changes: 22 additions & 0 deletions spirit/core/utils/deprecations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
import warnings

__all__ = [
'RemovedInNextVersionWarning',
'warn']


class RemovedInNextVersionWarning(DeprecationWarning):
""""""


def warn(message):
warnings.warn(
message,
RemovedInNextVersionWarning,
stacklevel=2)


warnings.simplefilter("default", RemovedInNextVersionWarning)
21 changes: 11 additions & 10 deletions spirit/core/utils/ratelimit/ratelimit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from django.conf import settings
from django.core.cache import caches

from ..deprecations import warn


TIME_DICT = {
's': 1,
Expand All @@ -22,18 +24,17 @@ def validate_cache_config():
# this cache so we do nothing
return

# Some third-party backend
# don't have a TIMEOUT option
if (not settings.ST_RATELIMIT_SKIP_TIMEOUT_CHECK and
cache.get('TIMEOUT', 1) is not None):
# todo: raise ConfigurationError in next version
# todo: warn(
# 'settings.ST_RATELIMIT_CACHE cache's TIMEOUT '
# 'must be None (never expire) and it may '
# 'be other than the default. '
# 'To skip this check, set '
# 'settings.ST_RATELIMIT_SKIP_TIMEOUT_CHECK to True.')
pass
# todo: ConfigurationError in next version
warn(
'settings.ST_RATELIMIT_CACHE cache\'s TIMEOUT '
'must be None (never expire) and it may '
'be other than the default cache. '
'To skip this check, for example when using '
'a third-party backend with no TIMEOUT option, set '
'settings.ST_RATELIMIT_SKIP_TIMEOUT_CHECK to True. '
'This will raise an exception in next version.')


class RateLimitError(Exception):
Expand Down

0 comments on commit 2144f32

Please sign in to comment.