Python 向用户添加属性google应用程序引擎

Python 向用户添加属性google应用程序引擎,python,google-app-engine,profiling,Python,Google App Engine,Profiling,使用Google App Engine(Python)保存用户配置文件的最佳方法是什么? 我解决这个问题的方法是创建另一个具有UserProperty的模型,但向用户请求配置文件时,我必须执行以下操作: if user: profile = Profile.all().filter('user =', user).fetch(1) if profile: property = s.get().property 有什么想法吗?没有,这是一种非常正确的方法(当然,您

使用Google App Engine(Python)保存用户配置文件的最佳方法是什么? 我解决这个问题的方法是创建另一个具有UserProperty的模型,但向用户请求配置文件时,我必须执行以下操作:

if user:
    profile = Profile.all().filter('user =', user).fetch(1)
    if profile:
        property = s.get().property

有什么想法吗?

没有,这是一种非常正确的方法(当然,您可能还希望将其中一些配置文件存储在memcache中;-)。这会很快,因为
user
字段上会有一个索引。如果这是您的要求,您肯定不能修改Google提供的用户模型。

如果您将用户的用户id设置为用户配置文件实体的密钥名称,您可以使用Profile.get\u by\u key\u name()获取它,这将比查询然后获取更快


Memcaching包括用户id作为密钥的一部分,将允许更快地访问配置文件。

这不是一个解决方案,而是一个警告

用户值不是用户的唯一且稳定的标识符。并且user_id属性只存在于google用户,而不存在于OpenId。所以不要相信这个解决方案