Commit 02101550 authored by Bartek Górny's avatar Bartek Górny

Moved file uploading from /view form to object_exchange

Uploading new file creates a new object with most properties copied

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10490 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 239455e5
......@@ -68,9 +68,41 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>o=state_change.object\n
mod=o.aq_parent\n
return context.REQUEST.RESPONSE.redirect(mod.absolute_url())\n
<value> <string>f=kw.get(\'file\',None)\n
typ=context.getPortalType()\n
\n
if f is None or not f:\n
raise Exception(\'DMSDocument_uploadFile called without file argument\')\n
\n
fname=f.filename\n
# we check for appropriate file type (by extension, using content_type_registry)\n
# we accept or suggest appropriate portal type\n
ctype=context.content_type_registry.findTypeName(fname,None,None)\n
if ctype is None and typ!=\'DMS File\':\n
raise Exception(\'This file should be uploaded into DMS File\')\n
if ctype is not None and ctype!=typ:\n
raise Exception(\'This file should be uploaded into \'+ctype)\n
\n
if hasattr(context,\'data\'): # this is a re-upload, we create a \'copy\'\n
docmod=context.restrictedTraverse(\'document_module\')\n
newob=docmod.newContent(portal_type=typ)\n
copylist=context.portal_types[typ].getInstanceBaseCategoryList()\n
# we copy many things, ingestion script may then overwrite some of these\n
# we rely on ingestion script to determine coordinates\n
copylist+=[\'title\',\'short_title\',\'index\',\'description\',\'subject\']\n
for a in copylist:\n
newob.setProperty(a,context.getProperty(a))\n
ob=newob\n
msg=\'object already had a file - a new object has been created\'\n
else:\n
ob=context\n
msg=\'file uploaded\'\n
\n
ob.manage_upload(f)\n
ob.DMS_ingestFile(f.filename)\n
url=ob.absolute_url() \n
\n
return context.REQUEST.RESPONSE.redirect(url+\'/view?portal_status_message=\'+msg)\n
</string> </value>
</item>
<item>
......@@ -87,7 +119,7 @@ return context.REQUEST.RESPONSE.redirect(mod.absolute_url())\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
<value> <string>*a,**kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -107,17 +139,31 @@ return context.REQUEST.RESPONSE.redirect(mod.absolute_url())\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>1</int> </value>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>state_change</string>
<string>a</string>
<string>kw</string>
<string>_getattr_</string>
<string>o</string>
<string>mod</string>
<string>None</string>
<string>f</string>
<string>context</string>
<string>typ</string>
<string>Exception</string>
<string>fname</string>
<string>ctype</string>
<string>hasattr</string>
<string>docmod</string>
<string>newob</string>
<string>_getitem_</string>
<string>copylist</string>
<string>_getiter_</string>
<string>ob</string>
<string>msg</string>
<string>url</string>
</tuple>
</value>
</item>
......@@ -134,7 +180,7 @@ return context.REQUEST.RESPONSE.redirect(mod.absolute_url())\n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>CreateNewOnUpload</string> </value>
<value> <string>DMSDocument_uploadFile</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
......
......@@ -105,7 +105,6 @@
<string>my_language</string>
<string>my_short_title</string>
<string>my_int_index</string>
<string>my_file</string>
<string>my_source_reference</string>
<string>my_translated_simulation_state_title</string>
<string>my_contributor_title_list</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ERP5Form.Form</string>
<string>ERP5Form</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>DMSDocument_uploadFile</string> </value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string>multipart/form-data</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_file</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>DMS_FileUploadDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>DMS_FileUploadDialog</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Upload file</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -187,7 +187,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Upload</string> </value>
<value> <string>File</string> </value>
</item>
</dictionary>
</value>
......
......@@ -106,7 +106,6 @@
<string>my_short_title</string>
<string>my_int_index</string>
<string>my_translated_simulation_state_title</string>
<string>my_file</string>
<string>my_source_reference</string>
<string>my_status_message</string>
<string>my_contributor_title_list</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.StandardFields</string>
<string>FileField</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_file</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Upload</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -85,9 +85,7 @@
<item>
<key> <string>script_name</string> </key>
<value>
<list>
<string>CreateNewOnUpload</string>
</list>
<tuple/>
</value>
</item>
<item>
......
......@@ -68,7 +68,8 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>ob=state_change.object\n
<value> <string># this will go away - we don\'t upload files in edit\n
ob=state_change.object\n
kw=ob.REQUEST\n
f=kw.get(\'my_file\',None)\n
\n
......
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