Browse Source

SHA512 hash for Model

Yann Weber 9 years ago
parent
commit
6aa32322a0
2 changed files with 8 additions and 2 deletions
  1. 1
    1
      EditorialModel/migrationhandler/dummy.py
  2. 7
    1
      EditorialModel/model.py

+ 1
- 1
EditorialModel/migrationhandler/dummy.py View File

@@ -39,5 +39,5 @@ class DummyMigrationHandler(object):
39 39
     
40 40
     def register_model_state(self, state_hash):
41 41
         if self.debug:
42
-            print("New EditorialModel sate registered : '%s'"%state_hash)
42
+            print("New EditorialModel state registered : '%s'"%state_hash)
43 43
 

+ 7
- 1
EditorialModel/model.py View File

@@ -27,7 +27,13 @@ class Model(object):
27 27
         self.load()
28 28
 
29 29
     def __hash__(self):
30
-        return int(hashlib.md5(str({uid: component.__hash__ for uid, component in self._components.items()}).encode('utf-8')).hexdigest(),16)
30
+        components_dump = ""
31
+        for _, comp in self._components['uids'].items():
32
+            components_dump += str(hash(comp))
33
+        h = hashlib.new('sha512')
34
+        h.update(components_dump.encode('utf-8'))
35
+        return int(h.hexdigest(), 16)
36
+
31 37
 
32 38
     def __eq__(self, other):
33 39
         return self.__hash__() == other.__hash__()

Loading…
Cancel
Save