jsocol/django-ratelimit — pull request #14 by mythmon (2013-03-12 20:38:06+00:00)
Title: Make key generation more flexible.

Instead of letting the backend generate keys all on it's own, this moves the key generation into functions that get passed to the decorator. These functions are called to generate keys like `ip:127.0.0.1` or `user:mythmon`. The backend then has a chance to munge these for it's own uses as well.

Using user-controlled functions allows for more interesting key generation, such as a key generator that uses a username, if the user is logged in, or an ip address otherwise (this key generator is `user_or_ip`, included in this commit).

Another benefit is easy extension of key generation. Just write a new function and pass it into the decorator. The function doesn't even have to be a part of django-ratelimit.

This commit was written with no regard for backwards compatibility, which may have been a mistake.