Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Export using sorted tuples instead of dict
To preserve order of exported XML, for stable diffs. This changes the export format, so exports need to be re-done. Here's how I did it: {{{py import glob dirname = 'src/Products.CMFPlomino/Products/CMFPlomino/tests/samples/' databases = glob.glob(os.path.join(dirname, '*.xml')) def import_databases(): for fn in databases: print 'importing', fn f = open(fn) i = os.path.splitext(os.path.basename(fn))[0] portal.invokeFactory('PlominoDatabase', id=i) db = getattr(portal, i) db.at_post_create_script() wf_tool = portal.portal_workflow wf_tool.doActionFor(db, 'publish') xmlstring=f.read() db.importDesignFromXML(xmlstring) db.refreshDB() import_databases() databases = [ "src/Products.CMFPlomino/Products/CMFPlomino/tests/filestoimport/devplomino.xml", "src/Products.CMFPlomino/Products/CMFPlomino/tests/filestoimport/hideWhenTest.xml", "src/Products.CMFPlomino/Products/CMFPlomino/tests/filestoimport/multilineDatagridTest.xml", "src/Products.CMFPlomino/Products/CMFPlomino/tests/filestoimport/replicadb.xml", "src/Products.CMFPlomino/Products/CMFPlomino/tests/filestoimport/with_datagrid_and_overlay.xml", ] import_databases() xmlstring = open("src/Products.CMFPlomino/Products/CMFPlomino/tests/filestoimport/replicadb-all-documents.xml").read() print 'importing', fn portal.replicadb.importFromXML(xmlstring=xmlstring) import glob dirname = 'src/Products.CMFPlomino/Products/CMFPlomino/tests/filestoimport/' databases = glob.glob(os.path.join(dirname, '*.xml')) def export_databases(): for fn in databases: print 'exporting', fn i = os.path.splitext(os.path.basename(fn))[0] db = getattr(portal, i, None) if not db: continue xmlstring = db.exportDesignAsXML(dbsettings=False) f = open(os.path.basename(fn), 'w') f.write(xmlstring) f.close() export_databases() dirname = 'src/Products.CMFPlomino/Products/CMFPlomino/tests/samples/' databases = glob.glob(os.path.join(dirname, '*.xml')) export_databases() ss = portal.replicadb.exportAsXML() f = open(os.path.join(dirname, 'replicadb-all-documents.xml'), 'w') f.write(ss) f.close()
- Loading branch information
6adf113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ebrehault this is a noisy commit, and migration of old databases is laborious.
But being confronted with unstable diffs on every commit, due to dictionary key ordering, is also a huge pain, clutters commit logs, and makes it easy to miss things.
Maybe we should keep both code paths around during
1.18.*
, and choose based on database version in the XML.6adf113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
6adf113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I see comments were stripped from the migration code sample I gave above. The import part should be done on Plomino
<= 1.18.1
, and the export after upgrade to> 1.18.1
.I'd like to change the commit message as described here:
http://darrinholst.com/post/359817782.html
Is this OK to do on an unmerged branch?
6adf113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebased, see cbc0c25 for new version ..