The entities didn't define a cmp opreation, they'll compared by their memory address.
You can try: set( [s.reference.key() for s in secList] ) or more efficient way: set( [SecondModel.get_value_for_datastore(s) for s in secList] ) ---------- keakon On Fri, Oct 22, 2010 at 4:00 PM, saintthor <[email protected]> wrote: > class FirstModel(db.Model): > prop = db.IntegerProperty() > > class SecondModel(db.Model): > reference = db.ReferenceProperty(FirstModel) > > first1 = FirstModel(...).put() > first2 = FirstModel(...).put() > first3 = FirstModel(...).put() > > fList = [first1,first2,first3] > > sList = [] > for i in range( 10 ): > sList.append( SecondModel( reference = fList[i%3] ).put() ) > > # now, i have 10 SecondModel references 3 FirstModel. > > q = SecondModel.all() > > secList = q.fetch( q.count() ) > > FirstSet = set( [s.reference for s in secList] ) > > print len( FirstSet ) > > # now, len( FirstSet ) should be 3, but there is 10. > > it regards same FirstModel referenced by different SecondModel as > different. how to make it regards it same? > > -- > 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. > > -- 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.
