From 40448c29928a3c8e436ea617a3f8f40e0ca1a72e Mon Sep 17 00:00:00 2001 From: Yusei Tahara <yusei@nexedi.com> Date: Fri, 21 Dec 2007 13:35:01 +0000 Subject: [PATCH] 2007-12-21 Yusei * Update file contribution part. Please update erp5_web and erp5_dms together. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18472 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../WebSite_contributeContent.xml | 44 +++++++++++-------- bt5/erp5_web/bt/change_log | 3 ++ bt5/erp5_web/bt/revision | 2 +- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_contributeContent.xml b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_contributeContent.xml index 7e6e593e1c..5f23b44764 100644 --- a/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_contributeContent.xml +++ b/bt5/erp5_web/SkinTemplateItem/portal_skins/erp5_web_widget_library/WebSite_contributeContent.xml @@ -3,11 +3,8 @@ <record id="1" aka="AAAAAAAAAAE="> <pickle> <tuple> - <tuple> - <string>Products.PythonScripts.PythonScript</string> - <string>PythonScript</string> - </tuple> - <none/> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + <tuple/> </tuple> </pickle> <pickle> @@ -73,10 +70,7 @@ contribute widget.\n \n **kw -- remaining params passed to the constructor\n -\n - TODO: rename source_project to follow_up (everywhere)\n """\n -\n from Products.ERP5.Document.Document import ConversionError\n from xmlrpclib import Fault\n from socket import error as SocketError\n @@ -95,15 +89,19 @@ if contribute_file is not None:\n kw[\'file\'] = contribute_file\n \n # We want to discover metadata synchronously\n -kw[\'discover_metadata\'] = 0 \n +kw[\'discover_metadata\'] = 0\n \n editable_mode = 1\n file_name = getattr(contribute_file, \'filename\', None)\n # try to ingest file\n failure = 0\n +new_content = None\n +merged_content = None\n +\n try:\n new_content = context.portal_contributions.newContent(**kw)\n - merged_content = new_content.discoverMetadata(file_name=file_name)\n + new_content.processFile()\n + merged_content = new_content.Document_convertToBaseFormatAndDiscoverMetadata(file_name=file_name)\n except ConversionError, Fault:\n # there are errors during ingestion content\n failure = 1\n @@ -116,21 +114,29 @@ except (TypeError, KeyError, AttributeError):\n # there\'s an unknow error occured\n failure = 1\n msg = \'Sorry, unknow error occured.\'\n - \n +\n +target = None\n +if merged_content is not None:\n + target = merged_content\n +elif new_content is not None:\n + target = new_content\n +else:\n + target = context\n +\n if failure:\n msg = context.Base_translateString(msg)\n - return context.Base_redirect(\'WebSite_viewAsSCALE\', \n - keep_items=dict(portal_status_message=msg,\n - editable_mode=0))\n + return target.Base_redirect(\'WebSite_viewAsSCALE\',\n + keep_items=dict(portal_status_message=msg,\n + editable_mode=0))\n # successful ingestion, show appropriate message\n -if merged_content is not new_content:\n +if merged_content is not None and merged_content is not new_content:\n msg = context.Base_translateString(\'Document successfully updated\')\n target = merged_content\n else:\n msg = context.Base_translateString(\'Document successfully created\')\n target = new_content\n \n -return target.Base_redirect(\'view\', \n +return target.Base_redirect(\'view\',\n keep_items=dict(portal_status_message=msg, \n editable_mode=editable_mode))\n </string> </value> @@ -193,17 +199,17 @@ return target.Base_redirect(\'view\', \n <string>getattr</string> <string>file_name</string> <string>failure</string> + <string>new_content</string> + <string>merged_content</string> <string>_apply_</string> <string>_getattr_</string> <string>context</string> - <string>new_content</string> - <string>merged_content</string> <string>msg</string> <string>TypeError</string> <string>KeyError</string> <string>AttributeError</string> - <string>dict</string> <string>target</string> + <string>dict</string> </tuple> </value> </item> diff --git a/bt5/erp5_web/bt/change_log b/bt5/erp5_web/bt/change_log index 2340629bde..6dab10fc9a 100644 --- a/bt5/erp5_web/bt/change_log +++ b/bt5/erp5_web/bt/change_log @@ -1,3 +1,6 @@ +2007-12-21 Yusei +* Update file contribution part. Please update erp5_web and erp5_dms together. + 2007-11-28 Yusei * Remove hardcoded ingestion email address from WebSite_viewContributeRenderer. Please use Email Ingestion Address preference instead. diff --git a/bt5/erp5_web/bt/revision b/bt5/erp5_web/bt/revision index b6fdfc3c05..09bd682e66 100644 --- a/bt5/erp5_web/bt/revision +++ b/bt5/erp5_web/bt/revision @@ -1 +1 @@ -609 \ No newline at end of file +611 \ No newline at end of file -- 2.30.9