From 5cc7884c039aaf09356af7be44bc507750f92965 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Sun, 10 Mar 2013 16:31:49 +0100 Subject: [PATCH] [gen] Bugfix: sort references. --- gen/wrappers/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gen/wrappers/__init__.py b/gen/wrappers/__init__.py index 88e92d5..48b7bf6 100644 --- a/gen/wrappers/__init__.py +++ b/gen/wrappers/__init__.py @@ -177,8 +177,12 @@ class AbstractWrapper(object): refs = getattr(self.o, fieldName, None) if not refs: return tool = self.tool - refs.sort(key=lambda x: getattr(tool.getObject(x), sortKey), - reverse=reverse) + # refs is a PersistentList: param "key" is not available. So perform the + # 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): '''If p_fieldNameOrClass is the name of a field, this method allows to