Commit 29c892ea authored by Ivan Tyagov's avatar Ivan Tyagov

Code cleanup. Do not unconditionally set file_name.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14201 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0851e562
...@@ -966,15 +966,14 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -966,15 +966,14 @@ 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 if file_name is not None:
# filename is often undefined....
self._setSourceReference(file_name)
# 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 ???
# filename is often undefined....
method = self._getTypeBasedMethod('getPreferredDocumentMetadataDiscoveryOrderList', method = self._getTypeBasedMethod('getPreferredDocumentMetadataDiscoveryOrderList',
fallback_script_id = 'Document_getPreferredDocumentMetadataDiscoveryOrderList') fallback_script_id = 'Document_getPreferredDocumentMetadataDiscoveryOrderList')
order_list = list(method()) order_list = list(method())
order_list.reverse() order_list.reverse()
# Start with everything until content - build a dictionary according to the order # Start with everything until content - build a dictionary according to the order
kw = {} kw = {}
for order_id in order_list: for order_id in order_list:
...@@ -993,20 +992,18 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin): ...@@ -993,20 +992,18 @@ class Document(XMLObject, UrlMixIn, ConversionCacheMixin, SnapshotMixin):
else: else:
result = method() result = method()
if result is not None: if result is not None:
# LOG('discoverMetadata %s' % order_id, 0, repr(result))
kw.update(result) kw.update(result)
# Prepare the content edit parameters - portal_type should not be changed # Prepare the content edit parameters - portal_type should not be changed
try: kw.pop('portal_type', None)
del(kw['portal_type']) # Try not to invoke an automatic transition here
except KeyError: self._edit(**kw)
pass # Finish ingestion by calling method
self._edit(**kw) # Try not to invoke an automatic transition here self.finishIngestion()
self.finishIngestion() # Finish ingestion by calling method
self.reindexObject() self.reindexObject()
return self.mergeRevision() # Revision merge is tightly coupled # Revision merge is tightly coupled
# to metadata discovery - refer to the documentation # to metadata discovery - refer to the documentation of mergeRevision method
# of mergeRevision method return self.mergeRevision()
security.declareProtected(Permissions.ModifyPortalContent, 'finishIngestion') security.declareProtected(Permissions.ModifyPortalContent, 'finishIngestion')
def finishIngestion(self): def finishIngestion(self):
......
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