Skip to content

Instantly share code, notes, and snippets.

@JshWright
Created May 28, 2010 18:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JshWright/417505 to your computer and use it in GitHub Desktop.
Save JshWright/417505 to your computer and use it in GitHub Desktop.
def ajaxsubmit(request):
new_msg = Message(msg = request.POST['msg'],
posted_by = request.POST['posted_by'])
new_msg.save()
# Again, we're just going to assume this always works
cmd = [{'cmd': 'inlinepush',
'params': {
'password': settings.APE_PASSWORD,
'raw': 'postmsg',
'channel': 'messages',
'data': {
'msg': new_msg.msg,
'posted_by': new_msg.posted_by,
'timestamp': new_msg.timestamp
}
}
}]
url = settings.APE_SERVER + urllib2.quote(json.dumps(cmd))
response = urllib2.urlopen(url)
# Updating the message is handled by APE, so just return an empty 200
return HttpResponse()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment