def deleteKeyword(self, kid): dao = KeywordDAO() if not dao.getKeywordById(kid): return jsonify(Error="Keyword Not Found"), 404 else: dao.delete(kid) return jsonify(DeleteStatus="OK"), 200
def getKeywordById(self, kid): dao = KeywordDAO() keyword = dao.getKeywordById(kid) if not keyword: return jsonify(Error="Keyword Not Found"), 404 else: result = self.build_keyword_dict(keyword) return jsonify(Keyword=result)
def updateKeyword(self, kid, form): dao = KeywordDAO() if not dao.getKeywordById(kid): return jsonify(Error="Keyword Not Found"), 404 else: if len(form) != 1: return jsonify(Error="Malformed Update Request"), 400 else: keyword = form['keyword'] if keyword: dao.update(kid, keyword) result = self.build_keyword_attributes(kid, keyword) return jsonify(Keyword=result), 200 else: return jsonify( Error="Unexpected attributes in update request"), 400