def check(self):
        if not THROTTLING_ENABLED:
            return

        if THROTTLING_IGNORE_ADMINS and self.request.user.is_superuser:
            return

        cache_key, timeout = self.get_cache_key()
        if not cache_key:
            return

        if timeout is False:  # view is disabled
            return HttpResponseBadRequest()

        if (timeout is None) or (timeout is 0):
            return

        if isinstance(timeout, basestring):
            if timeout.startswith('/'):
                return HttpResponseRedirect(timeout)
            else:
                callback = get_callable(timeout)
                maintenance_bundle = {
                    'view_func': self.view_func,
                    'view_args': self.view_args,
                    'view_kwargs': self.view_kwargs
                }

                return callback(self.request, maintenance_bundle)

        now = int(time.time() * 1000)
        last_access = cache.get(cache_key, 0)
        delta = now - last_access

        if delta >= timeout:
            cache.set(cache_key, now, THROTTLING_CACHE_EXPIRE)
            return

        congestion_view = self.view_throttling.get('congestion') or THROTTLING.get('congestion')
        if congestion_view:
            if congestion_view.startswith('/'):
                return HttpResponseRedirect(congestion_view)
            else:
                callback = get_callable(congestion_view)
                congestion_bundle = {
                    'view_func': self.view_func,
                    'view_args': self.view_args,
                    'view_kwargs': self.view_kwargs,
                    'timeout': timeout,
                    'delta': delta,
                }
                return callback(self.request, congestion_bundle)

        return HttpResponseBadRequest()
dataset/ETHPy150Open night-crawler/django-throttling/django_throttling/util.py/Throttle.check/original