Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing server side variable in custom script adapters #397

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog
4.1.3 (unreleased)
------------------

- Nothing changed yet.
- fix absence in custom script adapters space of server side flagged field
[sauzher]


4.1.2 (2023-01-02)
Expand Down
10 changes: 8 additions & 2 deletions src/collective/easyform/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,14 +584,20 @@ def getScript(self, context):
script.ZPythonScript_edit(params, body)
return script

def sanifyFields(self, form):
def sanifyFields(self, form, fields):
# Makes request.form fields accessible in a script
#
# Avoid Unauthorized exceptions since request.form is inaccesible

result = {}
for field in form:
result[field] = form[field]

# append in the results all serverside fields variable
for field in fields:
key = 'form.widgets.{}'.format(field)
if key not in result:
result[field] = fields[field]
return result

def checkWarningsAndErrors(self, script):
Expand Down Expand Up @@ -638,7 +644,7 @@ def executeCustomScript(self, result, form, req):
def onSuccess(self, fields, request):
# Executes the custom script
form = get_context(self)
resultData = self.sanifyFields(request.form)
resultData = self.sanifyFields(request.form, fields)
return self.executeCustomScript(resultData, form, request)


Expand Down