Permalink
Browse files

Merge pull request #13 from jsocol/callbacks

Allow callbacks to live outside of settings.py.
  • Loading branch information...
andymckay committed Feb 1, 2012
2 parents fe59ddf + 08f0841 commit 11945618fdaa7dc832e7382b241547567a77f4e6
Showing with 7 additions and 1 deletion.
  1. +7 −1 django_arecibo/wrapper.py
@@ -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):
return
exc_info = sys.exc_info()

0 comments on commit 1194561

Please sign in to comment.