Commit 38e77aaa authored by Ivan Tyagov's avatar Ivan Tyagov

Code refactoring. Meta data discover is done in an activity and errors can not...

Code refactoring. Meta data discover is done in an activity and errors can not be detected in this script.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14318 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7d288e0b
...@@ -87,31 +87,14 @@ if contribute_portal_type:\n ...@@ -87,31 +87,14 @@ if contribute_portal_type:\n
if contribute_file is not None:\n if contribute_file is not None:\n
kw[\'file\'] = contribute_file\n kw[\'file\'] = contribute_file\n
\n \n
kw[\'discover_metadata\'] = 0 # We want to discover metadata synchronously\n # We want to discover metadata synchronously \n
kw[\'discover_metadata\'] = 0 \n
\n \n
#try:\n new_content = context.portal_contributions.newContent(**kw)\n
if 1:\n msg = context.Base_translateString(\'Document successfully created\')\n
new_content = context.portal_contributions.newContent(**kw)\n
if hasattr(contribute_file, \'filename\'):\n
file_name = contribute_file.filename\n
else:\n
file_name = None\n
merged_content = new_content.discoverMetadata(file_name=file_name) # Consider putting an exception handler\n
if 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
editable_mode = 1\n
else:\n
#except Exception, e:\n
msg = \'There was a problem: ${exception}\'\n
msg = context.Base_translateString(msg, mapping=dict(exception=str(e)))\n
target = context\n
editable_mode = 0\n
\n \n
return target.Base_redirect(\'view\', keep_items=dict(portal_status_message=msg, editable_mode=editable_mode))\n return new_content.Base_redirect(\'view\', \n
keep_items=dict(portal_status_message=msg, editable_mode=1))\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -126,12 +109,6 @@ return target.Base_redirect(\'view\', keep_items=dict(portal_status_message=msg, ...@@ -126,12 +109,6 @@ return target.Base_redirect(\'view\', keep_items=dict(portal_status_message=msg,
<none/> <none/>
</value> </value>
</item> </item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>contribute_file=None, contribute_classification=None, contribute_source_project=None, contribute_portal_type=None, **kw</string> </value> <value> <string>contribute_file=None, contribute_classification=None, contribute_source_project=None, contribute_portal_type=None, **kw</string> </value>
...@@ -171,15 +148,8 @@ return target.Base_redirect(\'view\', keep_items=dict(portal_status_message=msg, ...@@ -171,15 +148,8 @@ return target.Base_redirect(\'view\', keep_items=dict(portal_status_message=msg,
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>new_content</string> <string>new_content</string>
<string>hasattr</string>
<string>file_name</string>
<string>merged_content</string>
<string>msg</string> <string>msg</string>
<string>target</string>
<string>editable_mode</string>
<string>dict</string> <string>dict</string>
<string>str</string>
<string>e</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
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