A Gateway is a sending endpoint, and associated authentication info
- that can be used to send messages.
+ that can be used to send messages.
name = models.CharField(max_length=128)
+ Use this gateway to send a message.
+ If ``celery`` is installed, then we assume they have set up the
+ ``celeryd`` server, and we queue for delivery. Otherwise, we will
+ It is strongly recommended to run this out of process,
+ especially if you are sending as part of an HttpRequest, as this
+ could take ~5 seconds per message that is to be sent.
if 'celery' in settings.INSTALLED_APPS:
def _send(self, message):
+ Actually do the work of sending the message. This is in a seperate
+ method so we can background it it possible.
+ assert message.status == "Unsent", "Re-sending SMS Messages not yet supported."
+ # We need to store the gateway that was used, so we can match up
+ # which gateway a reply has come through.
+ # Build up a URL-encoded request.
raw_data[self.recipient_keyword] = message.recipient.mobile
raw_data[self.content_keyword] = message.content
- assert message.uuid, "Message must have a valid UUID"
+ assert message.uuid, "Message must have a valid UUID"
raw_data[self.uuid_keyword] = message.uuid
data = urllib.urlencode(raw_data)
res = urllib.urlopen(self.base_url, data)
+ # Most servers will respond with something, which is only an
+ # interim status, which we can get for now, and maybe update later.
if status_msg.startswith('ERR') or status_msg.startswith('WARN'):
message.status = "Failed"
message.status_message = status_msg.split(': ')