mysociety/mapit — pull request #118 by mhl (2014-05-20 06:08:52+00:00)
Title: Fix rate-limited views when DEBUG is True

Since f7a36c the views decorated with @ratelimit failed if you
were using DummyCache as the backend (the default when DEBUG is True)
with an error like:

ValueError at /point/4326/0.119,52.205.html
Key 'rl-xxx.xxx.xxx.xxx-201405200701' not found

That was caused by the code:

except ValueError:
cache.add(key, '0', self.expire_after())
cache.incr(key)

... since the generic cache.incr wants to use the value returned
from the cache for that key, but DummyCache doesn't actually store
values.

Since the rate-limiting wasn't having any effect when DEBUG was
true anyway, just return early from the decorator to avoid this error.