views:

172

answers:

3

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

Any ideas?

A: 

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.

Alex Martelli
+3  A: 

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.

Wooble
A: 

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.

fccoelho