From 1f7c34bd1b8807681391fe6e830a48be0b1471b5 Mon Sep 17 00:00:00 2001 From: vangheem Date: Wed, 14 Nov 2018 16:22:19 -0500 Subject: [PATCH] fix value is none --- news/35.bugfix | 1 + plone/formwidget/namedfile/widget.py | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 news/35.bugfix diff --git a/news/35.bugfix b/news/35.bugfix new file mode 100644 index 0000000..32a1fc9 --- /dev/null +++ b/news/35.bugfix @@ -0,0 +1 @@ +Fix `NamedFileWidget` bug when trying to create value from `None`. [vangheem] \ No newline at end of file diff --git a/plone/formwidget/namedfile/widget.py b/plone/formwidget/namedfile/widget.py index c97920d..0f974fd 100644 --- a/plone/formwidget/namedfile/widget.py +++ b/plone/formwidget/namedfile/widget.py @@ -307,7 +307,8 @@ def extract(self, default=NOVALUE): dm = getMultiAdapter((self.context, self.field,), IDataManager) # For sub-widgets to function use a query() not get() data = dm.query(default) - data = _make_namedfile(data, self.field, self.context) + if data is not None: + data = _make_namedfile(data, self.field, self.context) return data # empty unnamed FileUploads should not count as a value