一种简单的方法是为每个用户分配一个唯一的URL标识符(或使用其键名),这样您就可以通过用户的ID查询该用户或基于唯一的URL标识符属性进行查询。如果需要,还可以使用其federated_id。
例:
class User(ndb.Model):
unique_identifier = ndb.Stringproperty()
...
class ProfilePage(webapp2.RequestHandler):
def get(self, profile_id):
#profile_id = key name of user
user = User.get_by_id(profile_id)
#profile_id = some unique field
#user = User.query(User.unique_identifier == profile_id).get()
if user:
#Get all posts for that user and render....
app = webapp2.WSGIApplication([('/', MainPage),
('/profile/<profile_id>', ProfilePage),])