Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #13 from jsocol/callbacks

Allow callbacks to live outside of settings.py.
  • Loading branch information...
commit 11945618fdaa7dc832e7382b241547567a77f4e6 2 parents fe59ddf + 08f0841
@andymckay authored
Showing with 7 additions and 1 deletion.
  1. +7 −1 django_arecibo/wrapper.py
View
8 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()
Please sign in to comment.
Something went wrong with that request. Please try again.