The difficulty is parsing the docs. :) "item_type must be one of the datastore value types, and cannot be list. See Datastore Value Types, above." http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ListProperty
"Other than the Python standard types and users.User, all classes described in this section are provided by the google.appengine.ext.db module." http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#Datastore_Value_Types The pitfall is the seemingly innocuous term 'datastore value types' (db.UserProperty isn't allowed, nor are any other db.*Property types (use the wrapped types instead of their Property facades)). The fix, for your example, is users.User instead of db.UserProperty... from google.appengine.api import users class Account( db.Model ): users = db.ListProperty( users.User ) a = Account() a.users.append( users.User( '[email protected]' ) ) a.put() -- G On Jan 9, 9:36 am, Kelly A <[email protected]> wrote: > I will start with the code: > > class account(db.Model): > users = db.ListProperty(db.UserProperty) > > def addUser(self, user): > self.users.append(user) > self.put() > > This of course does not work, UserProperty cannot be uses with > ListProperty. You must create some kind of shell to wrap around the > user property ala: > > class UserShell(dbModel): > def __init__(self, user): > self.user = user > self.user_id = user.user_id() > self.email = user.email() > > class Account(db.Model): > users = db.ListProperty(db.Key) > > def addUser(self, userShell): > self.users.append(userShell.key()) > self.put() > > def main(): > user = users.get_current_user() > userShell = UserShell(user) > myAccount = Account() > myAccount.addUser(userShell) > > So essentially you have to make a duplicate of a user object, just so > you can manage a list of users in your application.
-- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
