def get(self, topic_id): #done topic = DaoImpl.getTopic(topic_id) if topic: topicDict = Util.topicToDict(topic) self.set_status(200) self.write(simplejson.dumps(topicDict)) else: self.set_status(404) self.write(error('Topic not found.')) self.set_header("Content-Type", "application/json")
def post(self, topic_id):#done if self.request.body: linkDict = simplejson.loads(self.request.body) try: topic = DaoImpl.getTopic(topic_id) if not topic: raise TopicNotFoundException link = DaoImpl.createLinkFromDict(linkDict, topic) DaoImpl.addLinkToTopic(topic, link) self.set_status(200) self.write(simplejson.dumps(Util.linkToDict(link))) except Exception, e: self.set_status(400) self.write(error(e.__str__()))
def get(self, topic_id): topic = DaoImpl.getTopic(topic_id) topicDict = Util.topicToDict(topic) self.render("template.html", topic=topicDict)