Rufus Pollock avatar Rufus Pollock committed 0deb887

[changeset,sqlalchemy/changeset][s]: switch Changeset.manifest to a be a list rather than a dict as much simpler.

* E.g. do not need to worry about whether object_id is hashable (lists aren't!), simpler for sqlalchemy to work.

Comments (0)

Files changed (4)

         self.message = None
         self.timestamp = None
         self.metadata = {}
-        self.manifest = {}
+        self.manifest = []
 
     def save(self):
         self.compute_id()
         self.id = hashlib.sha1(value_to_hash).hexdigest()
 
     def compute_manifest_hash(self):
-        change_object_hashes = [ self.manifest[change_object_id].hash
-            for change_object_id
-            in sorted(self.manifest.keys()) ]
+        change_object_hashes = [ change_object.hash
+            for change_object
+            in self.manifest ]
         out = ''.join(change_object_hashes)
         return hashlib.sha1(out).hexdigest()
 

vdm/sqlalchemy/changeset.py

     changeset_table, change_object_table = make_tables(metadata)
 
     mapper(Changeset, changeset_table, properties={
-        'manifest': relationship(ChangeObject, backref='changeset',
-            collection_class=column_mapped_collection(change_object_table.c.object_id))
+        'manifest': relationship(ChangeObject, backref='changeset')
         },
         order_by=changeset_table.c.timestamp.desc()
         )

vdm/test/sqlalchemy/test_changeset.py

         assert cs.author == None, '%s' % cs.author
         assert cs.message == None
         assert cs.metadata == {}
-        assert cs.manifest == {}
+        assert cs.manifest == []
         cs.save()
         assert cs.id == '9feb6d00f5bd21b036e7a3d2f8e01ac6dd507fb6'
 
             'field2': 'bbbbbb'
             }
         cs = Changeset()
-        cs.manifest[co.object_id] = co
+        cs.manifest.append(co)
         cs.save()
         
         cs_id = '2a58c78bd6c17d49ffb1fe1afb2d09a93fdd5b2a'
         assert cs.id == cs_id, cs.id
         assert len(cs.manifest) == 1
-        assert cs.manifest[objectid] == co
+        assert cs.manifest[0]
         
         Session.add_all([cs, co])
         Session.commit()

vdm/test/test_changeset.py

         assert cs.author == None
         assert cs.message == None
         assert cs.metadata == {}
-        assert cs.manifest == {}
+        assert cs.manifest == []
 
     def test_02(self):
         co = ChangeObject()
             'field2': 'bbbbbb'
             }, sort_keys=True)
         cs = Changeset()
-        cs.manifest[co.object_id] = co
+        cs.manifest.append(co)
         cs.save()
 
         assert cs.id == '0925a971dc9d0ad3fdf1f6fca7d26ce6bb5e6f95', cs.id
         assert len(cs.manifest) == 1
-        assert cs.manifest[objectid] == co
+        assert cs.manifest[0] == co
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.