Default NUM_PROXIES to None instead of zero.

This commit is contained in:
kahnjw 2013-11-22 14:51:22 -08:00
parent 87e80b7be5
commit 900cb676e5
2 changed files with 2 additions and 3 deletions

View File

@ -63,7 +63,7 @@ DEFAULTS = {
'user': None, 'user': None,
'anon': None, 'anon': None,
}, },
'NUM_PROXIES': 0, 'NUM_PROXIES': None,
# Pagination # Pagination
'PAGINATE_BY': None, 'PAGINATE_BY': None,

View File

@ -25,7 +25,7 @@ class BaseThrottle(object):
""" """
num_proxies = api_settings.NUM_PROXIES num_proxies = api_settings.NUM_PROXIES
if 'HTTP_X_FORWARDED_FOR' in request.META and num_proxies > 0: if 'HTTP_X_FORWARDED_FOR' in request.META and num_proxies:
xff = request.META.get('HTTP_X_FORWARDED_FOR') xff = request.META.get('HTTP_X_FORWARDED_FOR')
return xff.split(',')[-min(num_proxies, len(xff))].strip() return xff.split(',')[-min(num_proxies, len(xff))].strip()
@ -222,7 +222,6 @@ class ScopedRateThrottle(SimpleRateThrottle):
# the `__init__` call. # the `__init__` call.
self.rate = self.get_rate() self.rate = self.get_rate()
self.num_requests, self.duration = self.parse_rate(self.rate) self.num_requests, self.duration = self.parse_rate(self.rate)
# We can now proceed as normal. # We can now proceed as normal.
return super(ScopedRateThrottle, self).allow_request(request, view) return super(ScopedRateThrottle, self).allow_request(request, view)