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

Prevent "Saved data" view from raising an exception if a field is not found #382

Open
wants to merge 1 commit into
base: 3.x
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
Empty file added news/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions news/381.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Prevent "Saved data" view from raising an exception if a field is not found
[frapell]
15 changes: 14 additions & 1 deletion src/collective/easyform/browser/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.schema import getFieldsInOrder
from ZPublisher.BaseRequest import DefaultPublishTraverse
import logging


logger = logging.getLogger(__name__)
PMF = MessageFactory("plone")


Expand Down Expand Up @@ -141,7 +143,18 @@ def update_schema(self):
fields = field.Fields(self.get_schema)
showFields = getattr(self.field, "showFields", [])
if showFields:
fields = fields.select(*showFields)
# showFields is a fixed list of field ids, and if those ids are no
# longer there, you get an exception, so first filter them.
existingFields = []
for fid in showFields:
if fid not in fields:
logger.warning(
"Field '%s' is no longer present in the form %s. Ignoring." %
(fid, '/'.join(self.context.getPhysicalPath()))
)
else:
existingFields.append(fid)
fields = fields.select(*existingFields)
return fields

@property
Expand Down