问题描述
使用Google App Engine(Python)保存用户个人资料的最佳方法是什么?为了解决这个问题,我要做的是创建另一个具有UserProperty的模型,但是要向用户请求配置文件,我必须执行以下操作:
What is the best way to save a user profile with Google App Engine (Python) ?What I did to solve this problem is create another Model, with a UserProperty, but requesting the profile from the user I have to do something like this:
if user:
profile = Profile.all().filter('user =', user).fetch(1)
if profile:
property = s.get().property
有什么想法吗?
推荐答案
如果将用户的user_id设置为用户的Profile实体的key_name,则可以使用Profile.get_by_key_name()来获取它,这比查询要快.然后抓取.
If you make the user_id of the user the key_name of the user's Profile entity, you can fetch it using Profile.get_by_key_name(), which will be faster than querying and then fetching.
通过将user_id作为密钥的一部分进行超级缓存将使访问配置文件的速度更快.
Memcaching including the user_id as part of the key will allow even faster access to the profile.
这篇关于向用户添加属性Google App Engine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!