Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Allow callbacks to live outside of #13

merged 1 commit into from

2 participants


Allow strings in the ARECIBO_SETTINGS['CALLBACKS'] list, so callback functions don't need to live in or get imported that early. e.g.

ARECIBO_SETTINGS['CALLBACKS'] = ['myapp.utils.arecibo_callback']
@andymckay andymckay merged commit 1194561 into andymckay:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 1, 2012
  1. Allow callbacks to live outside of

    James Socol authored
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 1 deletion.
  1. +7 −1 django_arecibo/
8 django_arecibo/
@@ -90,7 +90,13 @@ def __init__(self, request, status, **kw):
# will be tested against them before posting. This is good for
# blocking certain user agents under certain conditions for examples.
for callback in arecibo_setting('CALLBACKS', []):
- if not callback(request, status):
+ if callable(callback):
+ fn = callback
+ else: # Should be a string, anything else is wrong.
+ module, _, function = callback.rpartition('.')
+ mod = __import__(module)
+ fn = mod.getattr(function)
+ if not fn(request, status):
exc_info = sys.exc_info()
Something went wrong with that request. Please try again.