コード例 #1
0
ファイル: bpa_api.py プロジェクト: mizue31/bpa
    def get_all_post_titles(self, request):
        """Exposes an API endpoint to GET All Posts to current user.
        """
        query = Post01.query().order(-Post01.post_timestamp)

        #user = endpoints.get_current_user(scope)
        user = endpoints.get_current_user()
        plist = []

        for p in query:
            if user is None:
		raise endpoints.UnauthorizedException('unauthorized error')

            if p.post_author is None:
		email = "*****@*****.**"
            else:
		email = p.post_author.email()

	    logging.debug("get_all_post_titles:email:" + email)
            plist.append(
		Post(post_title=p.post_title, 
		     post_timestamp=p.post_timestamp, 
		     post_key=p.key.urlsafe(), 
		     post_author=email))


        # temporary
        # temporary
        # temporary

        #token_audience = oauth.get_client_id(scope)
        
        """
        author_str = "email:"+user.email() + \
                     ", auth_domain:" + user.auth_domain() + \
                     ", user_id:" + str(user.user_id()) + \
                     ", nickname:" + user.nickname() + \
                     ", user:"******", client_id:" + token_audience
        plist.append(Post(post_author=author_str))
        """

        ALL_POSTS = PostCollection(items=plist)

        return ALL_POSTS
コード例 #2
0
ファイル: bpa_api.py プロジェクト: mizue31/bpa
    def get_my_post_titles(self, request):
        #user = oauth.get_current_user(scope)
        user = endpoints.get_current_user()
        query = Post01.query(Post01.post_author == user).order(-Post01.post_timestamp)

        plist = []

        for p in query:
            if user is None:
		raise endpoints.UnauthorizedException('unauthorized error')
            plist.append(
		Post(post_title=p.post_title, 
		     post_timestamp=p.post_timestamp, 
		     post_key=p.key.urlsafe(), 
		     post_author=p.post_author.email()))

        ALL_POSTS = PostCollection(items=plist)
        return ALL_POSTS