コード例 #1
0
ファイル: bpa_api.py プロジェクト: mizue31/bpa
    def get_a_post(self, request):
        """Exposes an API endpoint to GET a Post to current user.
        """
	logging.debug("KEY1:" + str(request.post_key))
	key = ndb.Key(urlsafe=request.post_key)
	logging.debug("KEY2:" + str(key))
        p = Post01.get_by_id(key.id())
	logging.debug("p.TITLE:" + p.post_title)

	q_cmt = Comment01.query(Comment01.cmt_post == p.key).order(-Comment01.cmt_timestamp)
	clist = []
	for c in q_cmt:
		clist.append(
			Comment(
			cmt_content=c.cmt_content,
			cmt_timestamp=c.cmt_timestamp
			)
		)

	pc = Post_Comments(
		post_title = p.post_title,
		post_content = p.post_content,
		post_timestamp = p.post_timestamp,
		post_author = p.post_author.email(),
		post_key = p.key.urlsafe(),
		comments = clist)


	# user = oauth.get_current_user(scope) 
	logging.debug("post_key:" + p.key.urlsafe())
	return pc