Bug: Schema.moveField( ... after ) does incorrect reordering.
George Lee <[email protected]>
| Newsgroups | gmane.comp.web.zope.plone.archetypes.devel |
|---|---|
| Message-ID | <[email protected]> |
Suppose I have a schema S with fields F0, F1, F2. Then I expect
S.moveField( 'F0', after='F1')
to reorder the fields
F1, F0, F2,
but instead it reorders them
F1, F2, F0.
This is because the method calls
S._moveFieldToPosition('F0', pos=2),
which deletes F0
F1, F2
and then adds F0 to position 2
F1, F2, F0
Suggested fix:
def _moveFieldToPosition(self, name, pos):
"""Moves a field with the name 'name' to the position 'pos'
This method doesn't obey the assignement of fields to a schemata
"""
keys = self._names
oldpos = keys.index(name)
keys.remove(name)
if oldpos >= pos:
keys.insert(pos, name)
else:
keys.insert(pos - 1, name)
self._names = keys
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click