e1 and e1 are not datastore entities.  They are python instances of
subclasses of db.Model.  (The initial contents of these instances was
copied from the datastore but they may be changed subsequenty, changes
which do not affect each other or the datastore, unless you've done
something specific to make that happen).  Python instances can be
modified in a variety of ways.  The only way to modify datastore
entities is via {instance}.put() or db.put({instances}).)

Absent any other information, different class instances are different,
aka !=, even if they happen to have the same contents.  (Default
equality for class instances is by identity, not by content equality.)

You are, of course, free to define comparison methods between python
class instances.

Note that if you do e1.a = 7 and e2.a = 8, that is make the contents
different, e1.key() still == e2.key().

On Nov 8, 8:36 pm, jmay <[EMAIL PROTECTED]> wrote:
> It appears that entities cannot be compared directly:
>
>   e1 = MyEntity.get('longkeystringhere')
>   e2 = MyEntity.get('samekeystringhere')
>
> "e1 == e2" will return False even if identical keys are provided.
>
> But 'e1.key() == e2.key()' returns True.
>
> So to compare entities you must compare the keys.  I couldn't find
> this mentioned in the GAE docs.  Is this behavior intentional?
> Desirable?  It seems to me that comparing two entities ought to be the
> same as comparing the keys.
>
> -Jason
--~--~---------~--~----~------------~-------~--~----~
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