Commit 4ab7b7e2 authored by Nicolas Delaby's avatar Nicolas Delaby

Fix sorting

This sorting is inefficient if the id generator of module is random based.
This feature is replaced by a catalog query against creation_date parameter.
parent a18c90cd
......@@ -580,7 +580,8 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin,
# Find all document with same (reference, version, language)
kw = dict(portal_type=self.getPortalType(),
reference=self.getReference(),
where_expression=SQLQuery("validation_state NOT IN ('archived', 'cancelled', 'deleted')"))
where_expression=SQLQuery("validation_state NOT IN ('archived', 'cancelled', 'deleted')"),
sort_on='creation_date')
if self.getVersion():
kw['version'] = self.getVersion()
if self.getLanguage():
......@@ -589,8 +590,6 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin,
existing_document = None
# Select the first one which is not self and which
# shares the same coordinates
document_list = list(document_list)
document_list.sort(key=lambda x: x.getId())
for o in document_list:
if o.getRelativeUrl() != self.getRelativeUrl() and\
o.getVersion() == self.getVersion() and\
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment