def createOrUpdate(request): log.info("createOrUpdate") updatedId = -1 if (request.method == 'POST'): entryId = int(request.POST['entryId']) log.debug("entryId %d" % entryId) if (entryId == -1): entry = Entry() entry.author = getDefaultAuthor() entry.dateWritten = datetime.now() else: entry = Entry.objects.get(pk = entryId) entry.body = request.POST['body'] entry.save() updatedId = entry.id return HttpResponse(simplejson.dumps({ 'updatedId': updatedId }),\ mimetype='application/javascript')