Commit 993f5504 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

Solver Decision's configuration action uses always the same URL. all dynamic...

Solver Decision's configuration action uses always the same URL. all dynamic part should be included by FormBox, that will be also used in solver decision fast input UI.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@31842 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d58fadb5
......@@ -81,7 +81,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python:object.SolverDecision_getConfigurationUrl()</string> </value>
<value> <string>string:${object_url}/SolverDecision_viewConfiguration</string> </value>
</item>
</dictionary>
</pickle>
......@@ -97,7 +97,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python:object.SolverDecision_getConfigurationUrl()</string> </value>
<value> <string>python:object.getSolver() and object.getSolverValue().getConfigurationFormId()</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -53,22 +53,81 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
If no solver is linked, there is no configuration. If a solver\n
is linked, then return the solver configuration Url.\n
"""\n
solver = context.getSolver() # Not sufficient, should do getTargetSolver() - should we use 2 categories ?\n
if not solver:\n
return False\n
<value> <string encoding="cdata"><![CDATA[
# Updates attributes of an Zope document\n
# which is in a class inheriting from ERP5 Base\n
#\n
# TODO\n
# - Implement validation of matrix fields\n
# - Implement validation of list fields\n
#\n
from Products.Formulator.Errors import ValidationError, FormValidationError\n
from ZTUtils import make_query\n
\n
solver = context.getSolverValue()\n
request=context.REQUEST\n
\n
try:\n
return "%s/%s" % (context.absolute_url(), solver.getConfigurationFormId())\n
except AttributeError:\n
# the solver is not configurable.\n
return False\n
</string> </value>
# Define form basic fields\n
form = getattr(context,form_id)\n
# Validate\n
form.validate_all_to_request(request)\n
# Basic attributes\n
kw = {}\n
# Parse attributes\n
for f in form.get_fields():\n
k = f.id\n
v = getattr(request,k,None)\n
if v is not None:\n
if k[0:3] == \'my_\':\n
# We only take into account\n
# the object attributes\n
k = k[3:]\n
if getattr(v, \'as_dict\'): # FormBox\n
kw.update(v.as_dict())\n
else:\n
kw[k] = v\n
# Update basic attributes\n
context.log(repr(kw))\n
context.updateConfiguration(**kw)\n
context.reindexObject()\n
except FormValidationError, validation_errors:\n
# Pack errors into the request\n
field_errors = form.ErrorFields(validation_errors)\n
request.set(\'field_errors\', field_errors)\n
return form(request)\n
else:\n
# for web mode, we should use \'view\' instead of passed form_id\n
# after \'Save & View\'.\n
if context.REQUEST.get(\'is_web_mode\', False) and \\\n
not editable_mode:\n
form_id = \'view\'\n
\n
if not selection_index:\n
redirect_url = \'%s/%s?%s\' % (\n
context.absolute_url(),\n
form_id,\n
make_query({\'ignore_layout\':ignore_layout,\n
\'editable_mode\':editable_mode,\n
\'portal_status_message\':\'Data Updated.\',\n
})\n
)\n
else:\n
redirect_url = \'%s/%s?%s\' % (\n
context.absolute_url(),\n
form_id,\n
make_query({\'selection_index\':selection_index,\n
\'selection_name\':selection_name,\n
\'ignore_layout\':ignore_layout,\n
\'editable_mode\':editable_mode,\n
\'portal_status_message\':\'Data Updated.\',\n
})\n
)\n
\n
request[ \'RESPONSE\' ].redirect( redirect_url )\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -78,7 +137,7 @@ except AttributeError:\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>form_id, selection_index=0, selection_name=\'\', ignore_layout=0, editable_mode=1</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -98,17 +157,41 @@ except AttributeError:\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
<value> <int>5</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>form_id</string>
<string>selection_index</string>
<string>selection_name</string>
<string>ignore_layout</string>
<string>editable_mode</string>
<string>Products.Formulator.Errors</string>
<string>ValidationError</string>
<string>FormValidationError</string>
<string>ZTUtils</string>
<string>make_query</string>
<string>_getattr_</string>
<string>context</string>
<string>solver</string>
<string>request</string>
<string>getattr</string>
<string>form</string>
<string>kw</string>
<string>_getiter_</string>
<string>f</string>
<string>k</string>
<string>None</string>
<string>v</string>
<string>_getitem_</string>
<string>_write_</string>
<string>repr</string>
<string>_apply_</string>
<string>validation_errors</string>
<string>field_errors</string>
<string>False</string>
<string>AttributeError</string>
<string>redirect_url</string>
</tuple>
</value>
</item>
......@@ -120,12 +203,17 @@ except AttributeError:\n
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
<tuple>
<int>0</int>
<string></string>
<int>0</int>
<int>1</int>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SolverDecision_getConfigurationUrl</string> </value>
<value> <string>Base_editConfiguration</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="ERP5Form" module="Products.ERP5Form.Form"/>
<tuple/>
</tuple>
</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>Base_editConfiguration</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></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_configuration</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>SolverDecision_viewConfiguration</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>SolverDecision_view</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</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></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>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="FormBox" module="Products.ERP5Form.FormBox"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_configuration</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>
<item>
<key> <string>form_invalidated</string> </key>
<value> <string>Form invalidated.</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>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>formbox_target_id</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>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>formbox_target_id</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</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>invisible</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>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>formbox_target_id</string> </key>
<value> <string>Solver_viewConfiguration</string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>my_configuration</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:here.getSolverValue().getConfigurationFormId()</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