#9786: Files (and subclasses) override __eq__ but not __ne__
--------------------------------------------+-------------------------------
 Reporter:  xtian <[EMAIL PROTECTED]>  |       Owner:  nobody    
   Status:  new                             |   Milestone:            
Component:  Database layer (models, ORM)    |     Version:  SVN       
 Keywords:                                  |       Stage:  Unreviewed
Has_patch:  0                               |  
--------------------------------------------+-------------------------------
 We were trying to compare two model objects using the following function:

 {{{

 def allModelFieldsEqual(a, b):
     fields = [f.name for f in a._meta.fields]
     for name in fields:
         if getattr(a, name) != getattr(b, name):
             return False
     return True

 }}}

 This fails when the models contain FileFields, because File doesn't
 implement __ne__. Confusingly, because it implements __eq__, the values
 also compare equal.

 {{{
 (Pdb) !a.largeImage
 <ImageFieldFile: /images/first-large-image.png>
 (Pdb) !b.largeImage
 <ImageFieldFile: /images/first-large-image.png>
 (Pdb) !a.largeImage == b.largeImage
 True
 (Pdb) !a.largeImage != b.largeImage
 True
 }}}

 It should probably be implemented as:
 {{{
     def __ne__(self, other):
         return not self == other
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9786>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to