当前位置: 首页>>代码示例>>Python>>正文


Python User.get_user_by_id方法代码示例

本文整理汇总了Python中models.user.User.get_user_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_user_by_id方法的具体用法?Python User.get_user_by_id怎么用?Python User.get_user_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.user.User的用法示例。


在下文中一共展示了User.get_user_by_id方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_user_by_id [as 别名]
    def post (self):
        user_id = self.request.get ('user')
        print 'task queue recevied user id: %s' % user_id

        album_key = self.request.get ('album')
        fb_albums = json.loads (self.request.get ('fb_albums'))
        images = []

        user = User.get_user_by_id (user_id)
        album = ndb.Key (Album, int(album_key), parent=user.key).get ()

        graph = facebook.GraphAPI (user.access_token)

        albums_count = len(fb_albums)

        for fb_album in fb_albums:
            images_list = graph.get_object ("%s/photos" % fb_album["id"])

            if images_list:
                images.extend ([
                    Image (
                        id=image["id"],
                        source=image["images"][0]["source"], 
                        width=image["images"][0]["width"],
                        height=image["images"][0]["height"]
                    )
                    for image in images_list["data"]
                ])

        album.images = images
        album.put ()
开发者ID:yccheok,项目名称:SimpleLife,代码行数:33,代码来源:main.py

示例2: get

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_user_by_id [as 别名]
    def get (self, albumId):
        albums = []

        if self.current_user:
            user = User.get_user_by_id (self.current_user["id"])

            graph = facebook.GraphAPI (user.access_token)
            userInfo = graph.get_object ("%s" % user.id)

            if albumId:
                result = Album.query (albumId, ancestor = user.key).fetch ()
            else:
                result = [
                    {"id": album.key.id(), "name": album.name, "cover":
                        base64.b64encode (album.cover if album.cover else '')} 
                    for album in user.albums
                ]
            """
            all_albums = self.graph ('me/albums')
            
            if all_albums:
                print albums
                albums = [
                    dict (
                        name = album["name"],
                        icon = self.graph (album["cover_photo"]),
                        dikt = album
                    ) for album in all_albums["data"]
                ]
            """
        else:
            pass

        self.response.out.write (json.dumps (result))
开发者ID:yccheok,项目名称:SimpleLife,代码行数:36,代码来源:main.py

示例3: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_user_by_id [as 别名]
    def post (self, action):
        if self.current_user:
            data = json.loads (self.request.body)

            if self.current_user:
                user = User.get_user_by_id (self.current_user['id'])

            if data:
                album = user.add_album (data)
                taskqueue.add(url='/extractor', params = {'user': user.id,
                    "album": album.key.id (), 'fb_albums': json.dumps
                    (data["fb_albums"])})

                taskqueue.add(url='/create-cover', params = {'user': user.id,
                    "album": album.key.id (), 'fb_album': data["fb_albums"][0]["id"]})
开发者ID:boynux,项目名称:SimpleLife,代码行数:17,代码来源:main.py

示例4: get

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_user_by_id [as 别名]
 def get(self):
     aid = self.get_argument("aid")
     uname = self.get_current_user()
     user = User.get_user_by_name(uname)
     article = Article.get_by_aid(aid)
     F = False
     if len(article)>0:
         if len(user)>0:
             focus = User.get_all_focuson(user[0].uid)
             if len(focus)>0:
                 for one in focus:
                     if one.uid == article[0].uid:
                         F = True
                         break
         writer = User.get_user_by_id(article[0].uid)
         comments = Comment.get_all_comments(article[0].aid,200)
         Article.add_one_nvisit(aid)
         self.render("article.html",user=user,writer=writer,article=article,comments=comments,F=F)
开发者ID:oujiaqi,项目名称:suiyue,代码行数:20,代码来源:article.py

示例5: get

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_user_by_id [as 别名]
    def get (self, albumId):
        result = []

        if self.current_user:
            user = User.get_user_by_id (self.current_user["id"])

            graph = facebook.GraphAPI (user.access_token)
            userInfo = graph.get_object ("%s" % user.id)

            if albumId:
                result = Album.query (albumId, ancestor = user.key).fetch ()
            else:
                result = [
                    {"id": album.key.id(), "name": album.name, "cover": "/image/%s" % album.cover}
                    for album in user.albums
                ]
        else:
            pass

        self.response.out.write (json.dumps (result))
开发者ID:boynux,项目名称:SimpleLife,代码行数:22,代码来源:main.py

示例6: get

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_user_by_id [as 别名]
 def get(self):
     uname = self.get_current_user()
     user = User.get_user_by_name(uname)
     Vuid = self.get_argument("uid",None)
     Vuser = User.get_user_by_id(Vuid)
     F = False
     U = False
     if len(Vuser)>0:
         if len(user)>0:
             if Vuser[0].uid == user[0].uid:
                 U = True
             focus = User.get_all_focuson(user[0].uid)
             if len(focus)>0:
                 for one in focus:
                     if one.uid == Vuser[0].uid:
                         F = True
                         break
         if not U:
             User.add_one_nvisit(Vuser[0].uid)
         article = Article.get_by_uid(Vuser[0].uid)
         Acard = []
         Astory = []
         Afree = []
         for one in article:
             if one.Class == "card":
                 Acard.append(one)
             if one.Class == "story":
                 Astory.append(one)
             if one.Class == "free":
                 Afree.append(one)
         if len(Acard) > 10:
             Acard=Acard[:10]
         if len(Afree)>10:
             Afree=Afree[:10]
         if len(Astory)>10:
             Astory=Astory[:10]
         self.render("user.html",U=U,F=F,user=user,Acard=Acard,Astory=Astory,Afree=Afree,Vuser=Vuser)
     else:
         self.redirect("/")
开发者ID:oujiaqi,项目名称:suiyue,代码行数:41,代码来源:user.py

示例7: get

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_user_by_id [as 别名]
 def get(self):
     uname = self.get_current_user()
     user = User.get_user_by_name(uname)
     uid = self.get_argument("uid", None)
     Vuser = User.get_user_by_id(uid)
     fans = self.get_argument("fans", None)
     F = False
     u = "Ta"
     if len(Vuser)>0:
         if len(user)>0:
             if Vuser[0].uid == user[0].uid:
                 u = "我"
             focus = User.get_all_focuson(user[0].uid)
             if len(focus)>0:
                 for one in focus:
                     if one.uid == Vuser[0].uid:
                         F = True
                         break
         Vfans = User.get_all_fans(Vuser[0].uid)
         Vfocus = User.get_all_focuson(Vuser[0].uid)
         self.render("focus.html",fans=fans,u=u,F=F,user=user,Vuser=Vuser,Vfans=Vfans,Vfocus=Vfocus)
     else:
         self.redirect("/")
开发者ID:oujiaqi,项目名称:suiyue,代码行数:25,代码来源:fans.py

示例8: load_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_user_by_id [as 别名]
def load_user(user_id):
    try:
        return User.get_user_by_id(int(user_id))
    except ValueError:
        return None
开发者ID:hansihe,项目名称:FauxForum,代码行数:7,代码来源:__init__.py


注:本文中的models.user.User.get_user_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。