Author: mtredinnick
Date: 2009-03-08 05:01:59 -0500 (Sun, 08 Mar 2009)
New Revision: 10000

Modified:
   django/branches/releases/1.0.X/django/db/models/fields/files.py
   django/branches/releases/1.0.X/tests/regressiontests/file_storage/models.py
Log:
[1.0.x] Fixed #9508 -- Added an appropriate FileField.__hash__ implementation.

Required because we declare a custom __eq__ method.

Backport of r9997 from trunk.

Modified: django/branches/releases/1.0.X/django/db/models/fields/files.py
===================================================================
--- django/branches/releases/1.0.X/django/db/models/fields/files.py     
2009-03-08 10:01:22 UTC (rev 9999)
+++ django/branches/releases/1.0.X/django/db/models/fields/files.py     
2009-03-08 10:01:59 UTC (rev 10000)
@@ -32,6 +32,10 @@
     def __ne__(self, other):
         return not self.__eq__(other)
 
+    def __hash__(self):
+        # Required because we defined a custom __eq__.
+        return hash(self.name)
+
     # The standard File contains most of the necessary properties, but
     # FieldFiles can be instantiated without a name, so that needs to
     # be checked for here.

Modified: 
django/branches/releases/1.0.X/tests/regressiontests/file_storage/models.py
===================================================================
--- django/branches/releases/1.0.X/tests/regressiontests/file_storage/models.py 
2009-03-08 10:01:22 UTC (rev 9999)
+++ django/branches/releases/1.0.X/tests/regressiontests/file_storage/models.py 
2009-03-08 10:01:59 UTC (rev 10000)
@@ -54,6 +54,11 @@
 >>> p.mugshot != p1.mugshot
 True
 
+Bug #9508: Similarly to the previous test, make sure hash() works as expected
+(equal items must hash to the same value).
+>>> hash(p.mugshot) == hash(p2.mugshot)
+True
+
 # Bug #8175: correctly delete files that have been removed off the file system.
 >>> import os
 >>> p2 = Person(name="Fred")


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