def update_request(self, request_id, form):
        dao = RequestDAO()
        if not dao.getRequestById(request_id):
            return jsonify(Error="Post not found."), 404
        else:
            if len(form) != 6:
                return jsonify(Error="Malformed update request"), 400
            else:
                description = form['description']
                unit_price = form['max_unit_price']
                needed = form['needed']
                address = form['address']
                city = form['city']
                zip_code = form['zip_code']

                if int(needed) < 0:
                    return jsonify(
                        Error="Cannot put negative value in needed"), 400
                if description and unit_price and needed:
                    dao.update(request_id, description, needed, unit_price,
                               address, city, zip_code)
                    row = dao.getRequestById(request_id)
                    result = self.build_request_dict(row)
                    return jsonify(Part=result), 200
                else:
                    return jsonify(
                        Error="Unexpected attributes in update request"), 400
 def delete_request(self, request_id):
     dao = RequestDAO()
     if not dao.getRequestById(request_id):
         return jsonify(Error="Post not found."), 404
     else:
         dao.delete(request_id)
     return jsonify(DeleteStatus="OK"), 200
 def get_request_by_id(self, request_id):
     dao = RequestDAO()
     row = dao.getRequestById(request_id)
     if not row:
         return jsonify(Error="Post Not Found"), 404
     else:
         result = self.build_request_dict(row)
     return jsonify(Request_Post=result)