Beispiel #1
0
    def get_user(cls, username):
        """Get User instance for username

        Args:
         username:  string with username

        Returns:
         instance of User class for given username or None
        """
        return User.query(User.username == username).get()
Beispiel #2
0
    def get_friends(self, limit=10, offset=0):
        """Gets friends for current User object

        Returns:
         A list of User objects who are current in current User's friends list or
         None if User's friends list is empty
        """
        if bool(self.friends):
            f = memcache.get('friends', namespace=self.username)
            if not f:
                f = User.query(User.username.IN(self.friends)).order(-User.username)\
                        .fetch(limit, offset=offset)
                memcache.set('friends', f, namespace=self.username, time=1440)
            return f
        return None