Skip to content

Commit

Permalink
Passthrough arbitrary kwargs (Closes: #46)
Browse files Browse the repository at this point in the history
  • Loading branch information
lamby committed May 6, 2016
1 parent 34fbb5e commit f66e285
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions django_slack/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .utils import get_backend
from .app_settings import app_settings

def slack_message(template, context=None, attachments=None, fail_silently=None):
def slack_message(template, context=None, attachments=None, fail_silently=None, **kwargs):
backend = get_backend()
data = {}
context = dict(context or {}, settings=settings)
Expand Down Expand Up @@ -103,7 +103,7 @@ def slack_message(template, context=None, attachments=None, fail_silently=None):
data = {'payload': json.dumps(data)}

try:
backend.send(endpoint_url, data)
backend.send(endpoint_url, data, **kwargs)
except Exception:
if not fail_silently:
raise
8 changes: 4 additions & 4 deletions django_slack/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .app_settings import app_settings

class UrllibBackend(Backend):
def send(self, url, data):
def send(self, url, data, **kwargs):
r = urllib.request.urlopen(urllib.request.Request(
url,
urllib.parse.urlencode(data).encode('utf-8'),
Expand All @@ -25,19 +25,19 @@ def __init__(self):

self.session = requests.Session()

def send(self, url, data):
def send(self, url, data, **kwargs):
r = self.session.post(url, data=data, verify=False)

self.validate(r.headers['Content-Type'], r.text)

class ConsoleBackend(Backend):
def send(self, url, data):
def send(self, url, data, **kwargs):
print("I: Slack message:")
pprint.pprint(data, indent=4)
print("-" * 79)

class DisabledBackend(Backend):
def send(self, url, data):
def send(self, url, data, **kwargs):
pass

class CeleryBackend(Backend):
Expand Down

0 comments on commit f66e285

Please sign in to comment.