コード例 #1
0
 def insertPerson(self, form):
     if form and len(form) == 7:
         pfirstname = form['first_name']
         pmiddleinitial = form['middle_initial']
         plastname = form['last_name']
         email = form['email']
         plocation = form['location_of_p']
         pphone = form['phone']
         loginID = form['login_id']
         if pfirstname and plastname and pmiddleinitial and pphone and loginID and plocation and email:
             dao = PersonDAO()
             pid = dao.insert(pfirstname, pmiddleinitial, plastname, email,
                              plocation, pphone, loginID)
             result = {}
             result['p_id'] = pid
             result['first_name'] = pfirstname
             result['middle_initial'] = pmiddleinitial
             result['last_name'] = plastname
             result['email'] = email
             result['location_of_p'] = plocation
             result['phone'] = pphone
             result['login_id'] = loginID
             return jsonify(Person=result), 201
         else:
             return jsonify('Unexpected attributes in post request'), 401
     else:
         return jsonify(Error="Malformed post request"), 400
コード例 #2
0
 def insertPersonJson(self, json):
     dao = PersonDAO()
     new_person = dao.insert(json)
     return jsonify(new_person), 200