def get(self):
     session_id = get_session_id(session, request)
     dao = PersonaCharacteristicDAO(session_id)
     objts = dao.get_persona_characteristics_summary()
     dao.close()
     resp = make_response(json_serialize(objts, session_id=session_id))
     resp.headers['Content-Type'] = "application/json"
     return resp
    def get(self, name):
        session_id = get_session_id(session, request)
        dao = PersonaCharacteristicDAO(session_id)
        found_pc = dao.get_persona_characteristic(name)
        dao.close()

        resp = make_response(json_serialize(found_pc, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
    def delete(self, name):
        session_id = get_session_id(session, request)

        dao = PersonaCharacteristicDAO(session_id)
        dao.delete_persona_characteristic(name)
        dao.close()

        resp_dict = {'message': 'Persona Characteristic successfully deleted'}
        resp = make_response(json_serialize(resp_dict), OK)
        resp.contenttype = 'application/json'
        return resp
    def get(self):
        session_id = get_session_id(session, request)
        constraint_id = request.args.get('constraint_id', -1)

        dao = PersonaCharacteristicDAO(session_id)
        pcs = dao.get_persona_characteristics(constraint_id=constraint_id)
        dao.close()

        resp = make_response(json_serialize(pcs, session_id=session_id))
        resp.headers['Content-Type'] = "application/json"
        return resp
    def put(self, name):
        session_id = get_session_id(session, request)

        dao = PersonaCharacteristicDAO(session_id)
        upd_pc = dao.from_json(request)
        dao.update_persona_characteristic(upd_pc, name)
        dao.close()

        resp_dict = {'message': 'Persona Characteristic successfully updated'}
        resp = make_response(json_serialize(resp_dict), httplib.OK)
        resp.contenttype = 'application/json'
        return resp
    def post(self):
        session_id = get_session_id(session, request)

        dao = PersonaCharacteristicDAO(session_id)
        new_pc = dao.from_json(request)
        dao.add_persona_characteristic(new_pc)
        dao.close()

        resp_dict = {'message': 'Persona Characteristic successfully added'}
        resp = make_response(json_serialize(resp_dict, session_id=session_id),
                             httplib.OK)
        resp.contenttype = 'application/json'
        return resp
    def put(self, name):
        session_id = get_session_id(session, request)

        dao = PersonaCharacteristicDAO(session_id)
        upd_pc, ps, rss, rcs = dao.from_json(request)
        dao.update_persona_characteristic(upd_pc, name)
        if (ps != None):
            dao.assignIntentionalElements(ps, rss, rcs)
        dao.close()

        resp_dict = {'message': 'Persona Characteristic successfully updated'}
        resp = make_response(json_serialize(resp_dict), OK)
        resp.contenttype = 'application/json'
        return resp
    def post(self):
        session_id = get_session_id(session, request)
        dao = PersonaCharacteristicDAO(session_id)
        new_pc, ps, rss, rcs = dao.from_json(request)
        dao.add_persona_characteristic(new_pc)
        if (ps != None):
            dao.assignIntentionalElements(ps, rss, rcs)
        dao.close()

        resp_dict = {'message': new_pc.characteristic() + ' created'}
        resp = make_response(json_serialize(resp_dict, session_id=session_id),
                             OK)
        resp.contenttype = 'application/json'
        return resp