Commit 0694fc03 authored by Ivan Tyagov's avatar Ivan Tyagov

Do not rely on portal_catalog search results ordering.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14096 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3ed9f6ae
...@@ -45,7 +45,7 @@ from Products.ERP5Type.Utils import convertToUpperCase, convertToMixedCase ...@@ -45,7 +45,7 @@ from Products.ERP5Type.Utils import convertToUpperCase, convertToMixedCase
from Products.ERP5.Document.Url import UrlMixIn from Products.ERP5.Document.Url import UrlMixIn
from Products.ERP5.Tool.ContributionTool import MAX_REPEAT from Products.ERP5.Tool.ContributionTool import MAX_REPEAT
from zLOG import LOG from zLOG import LOG, INFO
_MARKER = [] _MARKER = []
VALID_ORDER_KEY_LIST = ('user_login', 'content', 'file_name', 'input') VALID_ORDER_KEY_LIST = ('user_login', 'content', 'file_name', 'input')
...@@ -801,7 +801,7 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -801,7 +801,7 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
# Find all document with same (reference, version, language) # Find all document with same (reference, version, language)
kw = dict(portal_type=self.getPortalDocumentTypeList(), kw = dict(portal_type=self.getPortalDocumentTypeList(),
reference=self.getReference(), reference=self.getReference(),
validation_state="!=deleted") # XXX Either use a system pref validation_state="!=cancelled") # XXX Either use a system pref
# or implement a class method # or implement a class method
# because !=delete is hardcoded # because !=delete is hardcoded
if self.getVersion(): kw['version'] = self.getVersion() if self.getVersion(): kw['version'] = self.getVersion()
...@@ -810,7 +810,9 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -810,7 +810,9 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
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
LOG('existing_document', 0, str(len(document_list))) document_list = list(document_list)
document_list.sort(lambda x,y: cmp(x.getId(), y.getId() ))
LOG('[DMS] Existing documents for %s' %self.getSourceReference(), INFO, len(document_list))
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\
...@@ -821,10 +823,10 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -821,10 +823,10 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
if existing_document is not None: if existing_document is not None:
document = existing_document document = existing_document
if existing_document.getPortalType() != self.getPortalType(): if existing_document.getPortalType() != self.getPortalType():
raise ValueError, "Ingestion may not change the type of an existing document" raise ValueError, "[DMS] Ingestion may not change the type of an existing document"
elif not _checkPermission(Permissions.ModifyPortalContent, existing_document): elif not _checkPermission(Permissions.ModifyPortalContent, existing_document):
self.setUniqueReference(suffix='unauthorized') self.setUniqueReference(suffix='unauthorized')
raise Unauthorized, "You are not allowed to update this document" raise Unauthorized, "[DMS] You are not allowed to update this document"
else: else:
update_kw = {} update_kw = {}
for k in self.propertyIds(): for k in self.propertyIds():
...@@ -964,7 +966,6 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -964,7 +966,6 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
user_login - this is a login string of a person; can be None if the user is user_login - this is a login string of a person; can be None if the user is
currently logged in, then we'll get him from session currently logged in, then we'll get him from session
""" """
# Get the order # Get the order
# Preference is made of a sequence of 'user_login', 'content', 'file_name', 'input' # Preference is made of a sequence of 'user_login', 'content', 'file_name', 'input'
self._setSourceReference(file_name) # XXX Who added this ??? self._setSourceReference(file_name) # XXX Who added this ???
...@@ -1000,7 +1001,6 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -1000,7 +1001,6 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
del(kw['portal_type']) del(kw['portal_type'])
except KeyError: except KeyError:
pass pass
self._edit(**kw) # Try not to invoke an automatic transition here self._edit(**kw) # Try not to invoke an automatic transition here
self.finishIngestion() # Finish ingestion by calling method self.finishIngestion() # Finish ingestion by calling method
self.reindexObject() self.reindexObject()
......
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