dear zopistas,

while trying to add a new schema field to an already registered plone
portlet, i got following traceback:

2011-02-14 23:11:55 ERROR Zope.SiteErrorLog 1297721515.110.63984381121
Traceback (innermost last):
  Module ZPublisher.Publish, line 127, in publish
  Module ZPublisher.mapply, line 77, in mapply
  Module ZPublisher.Publish, line 47, in call_object
  Module, line 123, in __call__
  Module zope.formlib.form, line 782, in __call__
  Module five.formlib.formbase, line 50, in update
  Module zope.formlib.form, line 745, in update
  Module zope.formlib.form, line 820, in setUpWidgets
  Module zope.formlib.form, line 408, in setUpEditWidgets
  Module zope.schema._bootstrapfields, line 173, in get
AttributeError: image_size

while - IMO - zope.schema throws that error justifiably, i think
zope.formlib should handle it more gracefully in setUpEditWidgets. i
think, this error comes with every schema upgrade for zope.formlib based
edit-forms. so, what do you think of following patch?

>From bcf7e2b7cb94b145cd502ad57e1363f2e6b4a879 Mon Sep 17 00:00:00 2001
From: Johannes Raggam <>
Date: Tue, 15 Feb 2011 12:38:50 +0100
Subject: [PATCH] after schema upgrades (e.g. for,
the edit screen cannot be rendered because there is no v
alue for the new field attribute. in this case, use the default value.

 zope/formlib/ |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/zope/formlib/ b/zope/formlib/
index 5df88cf..0d3ade3 100755
--- a/zope/formlib/
+++ b/zope/formlib/
@@ -405,7 +405,11 @@ def setUpEditWidgets(form_fields, form_prefix,
context, request,
         if ignore_request or readonly or not widget.hasInput():
             # Get the value to render
-            value = field.get(adapter)
+            try:
+                value = field.get(adapter)
+            except AttributeError:
+                # value not available after schema upgrade
+                value = field.default
         widgets.append((not readonly, widget))


i'm not sure if this would cause any unwanted side effects... actually i
think it won't.

johannes raggam

johannes raggam / thet
python plone zope development

Zope-Dev maillist  -
**  No cross posts or HTML encoding!  **
(Related lists - )

Reply via email to