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, ...@@ -580,7 +580,8 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin,
# Find all document with same (reference, version, language) # Find all document with same (reference, version, language)
kw = dict(portal_type=self.getPortalType(), kw = dict(portal_type=self.getPortalType(),
reference=self.getReference(), 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(): if self.getVersion():
kw['version'] = self.getVersion() kw['version'] = self.getVersion()
if self.getLanguage(): if self.getLanguage():
...@@ -589,8 +590,6 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin, ...@@ -589,8 +590,6 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin,
existing_document = None existing_document = None
# Select the first one which is not self and which # Select the first one which is not self and which
# shares the same coordinates # shares the same coordinates
document_list = list(document_list)
document_list.sort(key=lambda x: x.getId())
for o in document_list: for o in document_list:
if o.getRelativeUrl() != self.getRelativeUrl() and\ if o.getRelativeUrl() != self.getRelativeUrl() and\
o.getVersion() == self.getVersion() 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