示例#1
0
文件: main.py 项目: a85/doublespeak
    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")
示例#2
0
文件: main.py 项目: a85/doublespeak
 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__()))
示例#3
0
文件: main.py 项目: a85/doublespeak
 def get(self, topic_id):
     topic = DaoImpl.getTopic(topic_id)
     topicDict = Util.topicToDict(topic)
     self.render("template.html", topic=topicDict)