コード例 #1
0
 def build_comment_model_from_fb_comment(json_comment):
   comment = Comment(user_fb_id=json_comment["from"]["id"],
                     created_at=Utils.parse_utf_format_datetime(json_comment["created_time"]),
                     text=json_comment["message"])
   choosie_user = CacheController.get_user_by_fb_id(json_comment["from"]["id"])
   if choosie_user is None:
     comment.is_scraped = True
     comment.scraped_user_details = str(ScrapeCommentsHandler.build_user_details(json_comment))
   return comment
コード例 #2
0
 def build_comment_model_from_fb_comment(json_comment):
   comment = Comment(user_fb_id=json_comment["from"]["id"],
                     created_at=Utils.parse_utf_format_datetime(json_comment["created_time"]),
                     text=json_comment["message"])
   choosie_user = CacheController.get_user_by_fb_id(json_comment["from"]["id"])
   if choosie_user is None:
     comment.is_scraped = True
     comment.scraped_user_details = str(ScrapeCommentsHandler.build_user_details(json_comment))
   return comment
コード例 #3
0
 def get_serialized_comments(self):
     # updated_post.comments is a StringListProperty. Each comment_str is inflated to a dictionary
     # that looks like:
     # {"text": "blahblah",
     #  "user": {"fb_uid": "152343",
     #           ...}
     # }
     return [Comment.from_string_for_choosie_post(comment_str) for comment_str in self.comments if comment_str]
コード例 #4
0
  def post(self):
    fb_uid = str(self.request.get('fb_uid'))
    # TODO: Make sure text is Unicode
    text = self.request.get('text')

    # Since the post is taken from the cache, it might not be the most updated version
    # but that's ok, as it is only used as 'parent'
    choosie_post = CacheController.get_model(self.request.get('post_key'))
    comment = Comment(parent=choosie_post,
                      user_fb_id=self.request.get('fb_uid'),
                      text=text)
    comment.put()
    choosie_post.add_comment_to_post(comment)
    # Make sure the ChoosiePost's comments are invalidated in cache, so that next time
    # they are asked for, the updated are retreived.
    Comment.invalidate_comments(self.request.get('post_key'))

    self.response.write('Comment added.')
コード例 #5
0
 def get_serialized_comments(self):
     # updated_post.comments is a StringListProperty. Each comment_str is inflated to a dictionary
     # that looks like:
     # {"text": "blahblah",
     #  "user": {"fb_uid": "152343",
     #           ...}
     # }
     return [
         Comment.from_string_for_choosie_post(comment_str)
         for comment_str in self.comments if comment_str
     ]
コード例 #6
0
    def post(self):
        fb_uid = str(self.request.get('fb_uid'))
        # TODO: Make sure text is Unicode
        text = self.request.get('text')

        # Since the post is taken from the cache, it might not be the most updated version
        # but that's ok, as it is only used as 'parent'
        choosie_post = CacheController.get_model(self.request.get('post_key'))
        comment = Comment(parent=choosie_post,
                          user_fb_id=self.request.get('fb_uid'),
                          text=text)
        comment.put()
        choosie_post.add_comment_to_post(comment)
        # Make sure the ChoosiePost's comments are invalidated in cache, so that next time
        # they are asked for, the updated are retreived.
        Comment.invalidate_comments(self.request.get('post_key'))

        self.response.write('Comment added.')
コード例 #7
0
 def get_cached_comments(self):
     return Comment.get_comments_for_post(str(self.key()))
コード例 #8
0
 def get_cached_comments(self):
     return Comment.get_comments_for_post(str(self.key()))