开发者

How do I use a ListProperty(users.user) in a djangoforms.ModelForm on Google AppEngine?

I have been looking around a bit for info on how to do this. Essentially I have a Model:

class SharableUserAsset(db.Model):
  name = StringProperty()
  users = ListProperty(users.User)

My questions are:

  1. What is the best way to associate users to this value where they are not authenticated, visa vi invite from contacts list etc.?
  2. Is there a reasonable way to present a list control easily in a djangoforms.ModelForm?
  3. Once a user logs in I want to be able开发者_开发技巧 to check if that user is in the list for any number of SharableUserAsset class "records", how do I do that?
  4. Does user evaluate as a match to an email address or is there a way to look up a valid user against an email address?


In a query, comparing a list property to a value performs the test against the list members: list_property = value tests if the value appears anywhere in the list

http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ListProperty

So to find all the SharableUserAssets associated with the current user just query like:

user = users.get_current_user()
assets = SharableUserAsset.gql("WHERE users = :1", user)

Here's another reference dealing with ListProperty objects.

An App Engine User object contains an email address, and the email address can be retireved using the .email() method.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜