Permalink
Browse files

Allow callbacks to live outside of settings.py.

  • Loading branch information...
James Socol
James Socol committed Feb 1, 2012
1 parent fe59ddf commit 08f08414569f67f99d58cb5afd4f1fc83d50bee5
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 08f0841

Please sign in to comment.