Hi, I'm relatively new to GAE so I'm not sure if I'm overlooking
something relatively simple, but some help would be greatly
appreciated:

I'm working on an app where users can add others as contacts. To do
this, I have a User model and a Contact model:

class User(db.Model):
        username = db.StringProperty(required=True)
        firstname = db.StringProperty()
        lastname = db.StringProperty()
        email = db.EmailProperty(required=True)
        address = db.PostalAddressProperty(required=False)
        password = db.StringProperty(required=True)

class Contact(db.Model):
        contacter =
db.ReferenceProperty(User,required=True,collection_name='contacters')
        contactee =
db.ReferenceProperty(User,required=True,collection_name='contactees')
        accepted = db.BooleanProperty(required=True,default=False)

The relationships are unidirectional, so User A (contacter) can
request User B (contactee) as a contact and User B must then accept
User A. User A now has User B added as a contact, whereas User B
doesn't see anything different. To get a list of contacts for User A,
I'm using the back-reference property.

user = db.get(self.session['userkey']) //uses other info to get fetch
a User object
...
contactList = [] //blank array of contacts
if hasattr(user,'contacters'):
        for contact in user.contacters: //loops through all Contact objects
that refer to the current user as a contacter
                if contact.accepted == True:
                        contactList.append(contact.contactee)

The rest of the code is arbitrary, but in short I then loop through
the contactList array and print out the users for the "contacts" page.
The problem here is that it only works sporadically. Quite
astonishingly, I sometimes refresh the page and the contacts it finds
will disappear completely. There aren't any errors being logged, and
when I come back the next day or a few hours later it's back again. I
have an autocomplete script on a different page that queries another
class to get a list of matching contacts. It uses a similar back-
reference property, and this also works sporadically.

Are there any known issues / caching-features that I'm not aware of,
that might be causing this? Are back-references not the right way to
go about this? Thanks in advance!

-- 
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.

Reply via email to