开发者

add properties to users google app engine

W开发者_如何学编程hat 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

Any ideas?


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.

Memcaching including the user_id as part of the key will allow even faster access to the profile.


No, this is a pretty correct approach (though you might want to also store some of those profiles in memcache, of course;-). It's going to be fast, since there will be an index on the user field. You sure can't modify the Google-supplied user model, if that's what you're asking.


This is not a solution but a warning.

user value is not a unique and stable identifier for a User. And the user_id property only exists for google users not for OpenId. So don't trust this solution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜