Skip to content

Commit

Permalink
Fix for retaining order of ordered folders upon cloning
Browse files Browse the repository at this point in the history
  • Loading branch information
ddixon committed Jan 14, 2020
1 parent 3260278 commit c4884aa
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Products/ZopeVersionControl/nonversioned.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ def getNonVersionedData(self):
# subobjects that are references.
continue
contents[name] = aq_base(value)
return {'contents': contents, 'attributes': attributes}
order = []
if getattr(self.obj, '_objects', False):
order = [x['id'] for x in self.obj._objects]
return {'contents': contents, 'attributes': attributes, 'order': order}

def restoreNonVersionedData(self, data):
StandardNonVersionedDataAdapter.restoreNonVersionedData(
Expand All @@ -163,3 +166,18 @@ def restoreNonVersionedData(self, data):
# a BTreeFolder2, which doesn't need or want the
# _objects attribute.
# XXX This is a hackish way to check for BTreeFolder2s.
# Yes, we're repeating ourselves:
if not hasattr(obj, '_tree'):
for id in data.get('order', []):
try:
obj.moveObject(id, data['order'].index(id))
except AttributeError as e:
# maybe obj doesn't support .moveObject?
pass
except ValueError as e:
# item 'id' doesn't exist in obj?
pass
except Exception as e:
# Just bail, it's not worth failing on...
pass

0 comments on commit c4884aa

Please sign in to comment.