示例#1
0
文件: main.py 项目: Artanis/icecrate2
def update_lists(user_session=None):
  new_lists = bottle.request.json.get('lists')

  response = []
  for l in new_lists:
    # TODO: user auth!
    try:
      # TODO: try not to perform spurious updates
      _id, _rev = db.save(l)
      response.append(dict({"_id": _id, "_rev": _rev, "status": "ok"}))
    except couchdb.http.ResourceConflict:
      dict({"_id": l['_id'], "_rev": l['_rev'], "status": "conflict"})
      response.append(dict({"_id": l['_id'], "_rev": l['_rev'], "status": "conflict"}))

  return {
    "type": "bulk_update_lists",
    "data": response
  }
示例#2
0
文件: main.py 项目: Artanis/icecrate2
def update_households(user_session=None):
  new_houses = bottle.request.json.get('households')

  response = []
  for house in new_houses:
    # TODO: user auth!
    try:
      # TODO: try not to perform spurious updates
      _id, _rev = db.save(house)
      response.append(dict({"_id": _id, "_rev": _rev, "status": "ok"}))
    except couchdb.http.ResourceConflict:
      response.append({
        "_id": house.get('_id'),
        "_rev": house.get('_rev'),
        "status": "conflict"})

  return {
    "type": "bulk_update_households",
    "data": response
  }