[Checkins] SVN: z3c.form/trunk/src/z3c/form/widget.py When calling a field's defaultFactory attribute, we need to do it for a field with its context binded
Franco Pellegrini
cvs-admin at zope.org
Sat Feb 9 22:28:20 UTC 2013
Log message for revision 129241:
When calling a field's defaultFactory attribute, we need to do it for a field with its context binded
Changed:
U z3c.form/trunk/src/z3c/form/widget.py
-=-
Modified: z3c.form/trunk/src/z3c/form/widget.py
===================================================================
--- z3c.form/trunk/src/z3c/form/widget.py 2013-02-09 16:53:51 UTC (rev 129240)
+++ z3c.form/trunk/src/z3c/form/widget.py 2013-02-09 22:28:19 UTC (rev 129241)
@@ -105,15 +105,18 @@
(self.context, self.field),
interfaces.IDataManager).query()
# Step 1.2.2: If we still do not have a value, we can always use
- # the default value of the field, id set
+ # the default value of the field, if set
# NOTE: It should check field.default is not missing_value, but
# that requires fixing zope.schema first
- if ((value is self.field.missing_value or
- value is interfaces.NO_VALUE) and
- self.field.default is not None and
- self.showDefault):
- value = self.field.default
- lookForDefault = True
+ # We get a clone of the field with the context binded
+ field = self.field.bind(self.context)
+
+ if value is field.missing_value or value is interfaces.NO_VALUE:
+ default_value = field.default
+ if default_value is not None and self.showDefault:
+ value = field.default
+ lookForDefault = True
+
# Step 1.3: If we still have not found a value, then we try to get it
# from an attribute value
if ((value is interfaces.NO_VALUE or lookForDefault)
More information about the checkins
mailing list