[gen] Bugfix: sort references.

This commit is contained in:
Gaetan Delannay 2013-03-10 16:31:49 +01:00
parent da4f502ddc
commit 5cc7884c03

View file

@ -177,8 +177,12 @@ class AbstractWrapper(object):
refs = getattr(self.o, fieldName, None) refs = getattr(self.o, fieldName, None)
if not refs: return if not refs: return
tool = self.tool tool = self.tool
refs.sort(key=lambda x: getattr(tool.getObject(x), sortKey), # refs is a PersistentList: param "key" is not available. So perform the
reverse=reverse) # sort on the real list and then indicate that the persistent list has
# changed (the ZODB way).
refs.data.sort(key=lambda x: getattr(tool.getObject(x), sortKey),
reverse=reverse)
refs._p_changed = 1
def create(self, fieldNameOrClass, noSecurity=False, **kwargs): def create(self, fieldNameOrClass, noSecurity=False, **kwargs):
'''If p_fieldNameOrClass is the name of a field, this method allows to '''If p_fieldNameOrClass is the name of a field, this method allows to