Esempio n. 1
0
    def get(self, post_uid):

        post_obj = PostsDb.find_path(post_uid)  # find the path of post

        if not post_obj:
            self.render("404")
        else:

            # check it there is a user cookie
            if self.user_cookie:
                self.render("/permalink.html", post=post_obj, user=self.user_cookie)
Esempio n. 2
0
    def get(self, uid):
        self.response.headers["Content-Type"] = "application/json; charset=UTF-8"

        if not self.user_cookie:
            self.redirect("/login")
        else:
            post_obj = PostsDb.find_path(uid)
            json_post = Json()

            sub = post_obj.subject
            cont = post_obj.content
            created = post_obj.created.strftime("%b %d, %Y")
            last_time = post_obj.last_created.strftime("%b %d, %Y")

            json_post.set_variables(sub, cont, created, last_time)
            json_post.make_json_str()
            self.write(json_post.get_json())