Commit b852a826 authored by Julien Muchembled's avatar Julien Muchembled

Fix document ingestion so that no workflow method is called when the...

Fix document ingestion so that no workflow method is called when the transition doesn't exist for the current state.
This is mainly done by removing 'edit' transition on processing_workflow, to prevent duplicate processing of ingestion.
Reuse edit_workflow for all portal types with processing_status_workflow and update computation of revision (Document.getRevision).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27896 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ebcbc202
......@@ -5,19 +5,19 @@
</chain>
<chain>
<type>Drawing</type>
<workflow>local_permission_interaction_workflow, processing_status_workflow, document_interaction_workflow, document_publication_workflow</workflow>
<workflow>local_permission_interaction_workflow, edit_workflow, processing_status_workflow, document_interaction_workflow, document_publication_workflow</workflow>
</chain>
<chain>
<type>File</type>
<workflow>-edit_workflow, document_publication_workflow, document_interaction_workflow, local_permission_interaction_workflow, processing_status_workflow</workflow>
<workflow>document_publication_workflow, document_interaction_workflow, local_permission_interaction_workflow, processing_status_workflow</workflow>
</chain>
<chain>
<type>Image</type>
<workflow>-edit_workflow, document_interaction_workflow, document_publication_workflow, processing_status_workflow, local_permission_interaction_workflow</workflow>
<workflow>document_interaction_workflow, document_publication_workflow, processing_status_workflow, local_permission_interaction_workflow</workflow>
</chain>
<chain>
<type>PDF</type>
<workflow>local_permission_interaction_workflow, processing_status_workflow, document_interaction_workflow, document_publication_workflow</workflow>
<workflow>local_permission_interaction_workflow, edit_workflow, processing_status_workflow, document_interaction_workflow, document_publication_workflow</workflow>
</chain>
<chain>
<type>Person</type>
......@@ -25,7 +25,7 @@
</chain>
<chain>
<type>Presentation</type>
<workflow>document_publication_workflow, local_permission_interaction_workflow, processing_status_workflow, document_interaction_workflow</workflow>
<workflow>document_publication_workflow, local_permission_interaction_workflow, processing_status_workflow, document_interaction_workflow, edit_workflow</workflow>
</chain>
<chain>
<type>RSS Feed</type>
......@@ -33,11 +33,11 @@
</chain>
<chain>
<type>Spreadsheet</type>
<workflow>document_interaction_workflow, processing_status_workflow, document_publication_workflow, local_permission_interaction_workflow</workflow>
<workflow>edit_workflow, document_interaction_workflow, processing_status_workflow, document_publication_workflow, local_permission_interaction_workflow</workflow>
</chain>
<chain>
<type>Text</type>
<workflow>processing_status_workflow, local_permission_interaction_workflow, document_publication_workflow, document_interaction_workflow</workflow>
<workflow>processing_status_workflow, local_permission_interaction_workflow, document_publication_workflow, edit_workflow, document_interaction_workflow</workflow>
</chain>
<chain>
<type>URL Crawler</type>
......
......@@ -53,15 +53,16 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>object = state_change[\'object\']\n
object.uploadFile()\n
<value> <string>document = state_change[\'object\']\n
document.uploadFile()\n
\n
# do not activate conversion if the object is in portal_contributions\n
# because it will be gone from there in a second\n
# and activate would fail\n
if object.getParentValue().getPortalType() != \'Contribution Tool\':\n
object.processFile()\n
object.activate().Document_tryToConvertToBaseFormat()\n
if document.getParentValue().getPortalType() != \'Contribution Tool\' \\\n
and document.isSupportBaseDataConversion():\n
document.processFile()\n
document.activate().Document_tryToConvertToBaseFormat()\n
</string> </value>
</item>
<item>
......@@ -100,7 +101,7 @@ if object.getParentValue().getPortalType() != \'Contribution Tool\':\n
<tuple>
<string>state_change</string>
<string>_getitem_</string>
<string>object</string>
<string>document</string>
<string>_getattr_</string>
</tuple>
</value>
......
......@@ -35,7 +35,6 @@
<string>cancel_action</string>
<string>delete</string>
<string>delete_action</string>
<string>edit</string>
<string>embed</string>
<string>publish</string>
<string>publish_action</string>
......
......@@ -31,7 +31,6 @@
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>edit</string>
<string>extract</string>
</tuple>
</value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The edit workflow method is trigerred each time a document is modified. It is necessary so that the embed automatic script can be invoked (XXX - double check this)</string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Edit</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -25,7 +25,6 @@
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>edit</string>
<string>update_file_metadata</string>
<string>upload_file</string>
</tuple>
......
......@@ -27,7 +27,6 @@
<tuple>
<string>convert_action</string>
<string>convert_file</string>
<string>edit</string>
<string>process_file</string>
<string>upload_file</string>
</tuple>
......
......@@ -26,7 +26,6 @@
<value>
<tuple>
<string>detect_uploaded_file</string>
<string>edit</string>
<string>upload_file</string>
</tuple>
</value>
......
......@@ -27,7 +27,6 @@
<tuple>
<string>convert_action</string>
<string>detect_converted_file</string>
<string>edit</string>
<string>process_file</string>
<string>upload_file</string>
</tuple>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>action called when editing a document</string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Edit</string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2009-07-03 jm
* Remove 'edit' transition on processing_status_workflow and reuse edit_workflow.
2009-05-15 yusei
* Add my_editor_field to Base_viewDMSFieldLibrary.
......
988
\ No newline at end of file
989
\ No newline at end of file
......@@ -3,25 +3,26 @@ Document Ingestion Message | document_ingestion_workflow
Document Ingestion Message | edit_workflow
Drawing | document_interaction_workflow
Drawing | document_publication_workflow
Drawing | edit_workflow
Drawing | local_permission_interaction_workflow
Drawing | processing_status_workflow
File | -edit_workflow
File | document_interaction_workflow
File | document_publication_workflow
File | local_permission_interaction_workflow
File | processing_status_workflow
Image | -edit_workflow
Image | document_interaction_workflow
Image | document_publication_workflow
Image | local_permission_interaction_workflow
Image | processing_status_workflow
PDF | document_interaction_workflow
PDF | document_publication_workflow
PDF | edit_workflow
PDF | local_permission_interaction_workflow
PDF | processing_status_workflow
Person | local_permission_interaction_workflow
Presentation | document_interaction_workflow
Presentation | document_publication_workflow
Presentation | edit_workflow
Presentation | local_permission_interaction_workflow
Presentation | processing_status_workflow
RSS Feed | document_publication_workflow
......@@ -29,10 +30,12 @@ RSS Feed | edit_workflow
RSS Feed | local_permission_interaction_workflow
Spreadsheet | document_interaction_workflow
Spreadsheet | document_publication_workflow
Spreadsheet | edit_workflow
Spreadsheet | local_permission_interaction_workflow
Spreadsheet | processing_status_workflow
Text | document_interaction_workflow
Text | document_publication_workflow
Text | edit_workflow
Text | local_permission_interaction_workflow
Text | processing_status_workflow
URL Crawler | document_publication_workflow
......
......@@ -980,26 +980,14 @@ class Document(PermanentURLMixIn, XMLObject, UrlMixIn, ConversionCacheMixin, Sna
of the current object. The return value is a string
in order to be consistent with the property sheet
definition.
NOTE: for now, workflow choice is hardcoded. This is
an optimisation hack. If a document does neither use
edit_workflow or processing_status_workflow, the
first workflow in the chain has prioriot. Better
implementation would require to be able to define
which workflow in a chain is the default one for
revision tracking (and for modification date).
"""
portal_workflow = getToolByName(self, 'portal_workflow')
wf_list = list(portal_workflow.getWorkflowsFor(self))
wf = portal_workflow.getWorkflowById('edit_workflow')
if wf is not None: wf_list = [wf] + wf_list
wf = portal_workflow.getWorkflowById('processing_status_workflow')
if wf is not None: wf_list = [wf] + wf_list
for wf in wf_list:
history = wf.getInfoFor(self, 'history', None)
if history:
return str(len(filter(lambda x:x.get('action', None) in ('edit', 'upload'), history)))
return ''
"""
revision = len(self.getWorkflowInfo('history', 'edit_workflow'))
# XXX Also look at processing_status_workflow for compatibility.
for history_item in self.getWorkflowInfo('history',
'processing_status_workflow'):
if history_item.get('action') == 'edit':
revision += 1
return str(revision)
security.declareProtected(Permissions.AccessContentsInformation, 'getRevisionList')
def getRevisionList(self):
......@@ -1007,10 +995,7 @@ class Document(PermanentURLMixIn, XMLObject, UrlMixIn, ConversionCacheMixin, Sna
Returns the list of revision numbers of the current document
by by analysing the change log of the current object.
"""
revision = self.getRevision()
if revision == '':
return []
return [str(r) for r in range(0, int(self.getRevision()))]
return map(str, range(1, 1 + int(self.getRevision())))
security.declareProtected(Permissions.ModifyPortalContent, 'mergeRevision')
def mergeRevision(self):
......
......@@ -364,14 +364,9 @@ class ContributionTool(BaseTool):
# If we need to discoverMetadata synchronously, it must
# be for user interface and should thus be handled by
# ZODB scripts
# XXX converting state is for only document which is necessary to
# convert base format.
portal_workflow = self.getPortalObject().portal_workflow
if 'processing_status_workflow' in portal_workflow.getChainFor(document):
document.processFile() # move to converting state.
document.activate().Document_convertToBaseFormatAndDiscoverMetadata(
file_name=name, user_login=user_login)
document.activate(after_path_and_method_id=(document.getPath(),
('convertToBaseFormat', 'Document_tryToConvertToBaseFormat'))) \
.discoverMetadata(file_name=name, user_login=user_login)
else:
if existing_document.isExternalDocument():
document = existing_document
......
......@@ -206,14 +206,14 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
if not run: return
printAndLog('\nTest Revision System')
# create a test document
# revision should be 0
# revision should be 1
# upload file (can be the same) into it
# revision should now be 1
# edit the document with any value or no values
# revision should now be 2
# edit the document with any value or no values
# revision should now be 3
# contribute the same file through portal_contributions
# the same document should now have revision 3 (because it should have done mergeRevision)
# getRevisionList should return (0, 1, 2, 3)
# the same document should now have revision 4 (because it should have done mergeRevision)
# getRevisionList should return (1, 2, 3, 4)
filename = 'TEST-en-002.doc'
file = makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file)
......@@ -223,20 +223,20 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
document_url = document.getRelativeUrl()
def getTestDocument():
return self.portal.restrictedTraverse(document_url)
self.failUnless(getTestDocument().getRevision() == '0')
self.failUnless(getTestDocument().getRevision(), '1')
getTestDocument().edit(file=file)
transaction.commit()
self.tic()
self.failUnless(getTestDocument().getRevision() == '1')
self.failUnless(getTestDocument().getRevision(), '2')
getTestDocument().edit(title='Hey Joe')
transaction.commit()
self.tic()
self.failUnless(getTestDocument().getRevision() == '2')
self.failUnless(getTestDocument().getRevision(), '3')
another_document = self.portal.portal_contributions.newContent(file=file)
transaction.commit()
self.tic()
self.failUnless(getTestDocument().getRevision() == '3')
self.failUnless(getTestDocument().getRevisionList() == ['0', '1', '2'] )
self.failUnless(getTestDocument().getRevision(), '4')
self.failUnless(getTestDocument().getRevisionList(), ['1', '2', '3', '4'])
def test_03_Versioning(self,quiet=QUIET,run=RUN_ALL_TEST):
"""
......
......@@ -304,7 +304,6 @@ class TestIngestion(ERP5TypeTestCase):
printAndLog('Ingesting file: ' + filename)
f = makeFileUpload(filename)
context.edit(file=f)
context.convertToBaseFormat()
context.reindexObject()
transaction.commit()
self.tic()
......@@ -328,7 +327,6 @@ class TestIngestion(ERP5TypeTestCase):
filename = 'TEST-en-002.' + format
f = makeFileUpload(filename)
context.edit(file=f)
context.convertToBaseFormat()
context.reindexObject()
transaction.commit()
self.tic()
......
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