Commit 7c94ef28 authored by Klaus Wölfel's avatar Klaus Wölfel

Reimplement Data Stream append as Exchange Dialog

The previous implementation did not support saving categories in view form.
It is better to use standard Base_edit in view forms and put actions which are other than "save"
into a dialog.
parent 7be7fcb6
context.appendData(append_file.read())
message = context.Base_translateString("Data Stream updated.")
return context.Base_redirect(
'view',
keep_items=dict(portal_status_message=message)
)
......@@ -50,11 +50,11 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id, **kw</string> </value>
<value> <string>append_file, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>DataStream_saveDataStream</string> </value>
<value> <string>DataStream_appendFile</string> </value>
</item>
</dictionary>
</pickle>
......
request = container.REQUEST
response = request.response
field_prefix = 'field_my_' # Prevent changing the prefix through publisher
field_prefix_len = len(field_prefix)
fields = {}
for key, value in request.form.items():
if key.startswith(field_prefix) and value:
fields[key[field_prefix_len:]] = value
if fields.has_key('append_file'):
context.appendData(fields['append_file'].read())
del fields['append_file']
context.edit(**fields)
message = context.Base_translateString("Data Stream updated")
return context.Base_redirect(
'view',
keep_items=dict(portal_status_message=message),
**kw
)
......@@ -14,7 +14,7 @@
</item>
<item>
<key> <string>action</string> </key>
<value> <string>DataStream_saveDataStream</string> </value>
<value> <string>Base_edit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -90,7 +90,6 @@
<string>my_filename</string>
<string>my_size</string>
<string>my_file</string>
<string>my_append_file</string>
<string>my_translated_validation_state_title</string>
</list>
</value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<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>DataStream_appendFile</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</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>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>your_append_file</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>DataStream_viewAppendFileExchangeDialog</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>DataStream_viewAppendFileExchangeForm</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>Append 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>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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