示例#1
0
 def get(self):
     page = force_int(self.get_argument('page', 1), 1)
     category = self.get_argument('category', None)
     limit = 12
     hot_users = User.get_users(category='hot', limit=limit)
     new_users = User.get_users(category='new', limit=limit)
     page_count = 0
     users = []
     url = '/users'
     if category == 'all':
         user_count = count(User.get_users(page=None))
         page_count = (user_count + config.user_paged -
                       1) // config.user_paged
         users = User.get_users(page=page)
         url = '/users?category=all'
     elif category == 'online':
         users = set()
         online = rd.smembers("online") or [0]
         online = [int(i) for i in online]
         users = User.select(lambda rv: rv.id in online)
         print users
         user_count = len(users)
         page_count = (user_count + config.user_paged -
                       1) // config.user_paged
         url = '/users?category=online'
     return self.render("user/show.html",
                        users=users,
                        hot_users=hot_users,
                        new_users=new_users,
                        page=page,
                        page_count=page_count,
                        url=url,
                        category=category)
示例#2
0
文件: user.py 项目: SunnyKale/collipa
 def get(self):
     page = force_int(self.get_argument('page', 1), 1)
     category = self.get_argument('category', None)
     limit = 12
     hot_users = User.get_users(category='hot', limit=limit)
     new_users = User.get_users(category='new', limit=limit)
     page_count = 0
     users = []
     url = '/users'
     if category == 'all':
         user_count = count(User.get_users(page=None))
         page_count = (user_count + config.user_paged - 1) // config.user_paged
         users = User.get_users(page=page)
         url = '/users?category=all'
     elif category == 'online':
         users = set()
         online = rd.smembers("online") or [0]
         online = [int(i) for i in online]
         users = User.select(lambda rv: rv.id in online)
         print users
         user_count = len(users)
         page_count = (user_count + config.user_paged - 1) // config.user_paged
         url = '/users?category=online'
     return self.render("user/show.html", users=users, hot_users=hot_users,
             new_users=new_users, page=page,
             page_count=page_count, url=url, category=category)
示例#3
0
文件: api.py 项目: zs1621/collipa
 def send_online(cls):
     online = rd.smembers("online")
     logging.info("Online user count is " + unicode(len(online)))
     for user in cls.users:
         try:
             user.write_message({"type": "online", "count": unicode(len(online))})
         except:
             logging.error("Error sending online user count", exc_info=True)
示例#4
0
文件: api.py 项目: SunnyKale/collipa
 def send_online(cls):
     online = rd.smembers("online")
     logging.info("Online user count is " + unicode(len(online)))
     for user in cls.users:
         try:
             user.write_message({"type": "online", "count": unicode(len(online))})
         except Exception as e:
             logging.error("Error sending online user count", exc_info=True)
             if type(e).__name__ == "AttributeError":
                 try:
                     WebSocketHandler.users.remove(user)
                     rd.srem("online", user.user_id)
                     WebSocketHandler.online.remove(user.user_id)
                 except:
                     pass
示例#5
0
文件: api.py 项目: catsky/collipa
 def send_online(cls):
     online = rd.smembers("online")
     logging.info("Online user count is " + unicode(len(online)))
     for user in cls.users:
         try:
             user.write_message({
                 "type": "online",
                 "count": unicode(len(online))
             })
         except Exception as e:
             logging.error("Error sending online user count", exc_info=True)
             if type(e).__name__ == "AttributeError":
                 try:
                     WebSocketHandler.users.remove(user)
                     rd.srem("online", user.user_id)
                     WebSocketHandler.online.remove(user.user_id)
                 except:
                     pass
示例#6
0
 def is_online(self):
     online = rd.smembers("online") or [0]
     online = [int(i) for i in online]
     return self.id in online
示例#7
0
 def is_online(self):
     online = rd.smembers("online") or [0]
     online = [int(i) for i in online]
     return self.id in online