views:

78

answers:

1

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?
+1  A: 

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.

Robert
Good answer to that part, but my question is also slightly about storing the user in a useful way as an invite, say from the contact list of a gmail account. Then when the user who was invited comes to the site logged in with that account associating the two. I suppose for me the problem is: while a user contains and email, an email is not a user.
Gabriel
Thats one of the reasons I don't use the Google user authentication. I made my own, and just store email addresses. Another reason I don't like it, is it takes you off site to a non branded page to log in. But, a good thing about using Google's authentication, is they validate the user's email for you.So I just skipped using User objects, and only store email strings with StringListProperty
Robert
Point taken, this is likely to be sufficient for now.
Gabriel