[Checkins] SVN: zc.form/trunk/src/zc/form/field.py - fixed binding
problem of union field (this problem might be around in other
places too, i haven't had time to look)
Christian Theune
ct at gocept.com
Thu Jun 22 16:41:21 EDT 2006
Log message for revision 68791:
- fixed binding problem of union field (this problem might be around in other places too, i haven't had time to look)
Changed:
U zc.form/trunk/src/zc/form/field.py
-=-
Modified: zc.form/trunk/src/zc/form/field.py
===================================================================
--- zc.form/trunk/src/zc/form/field.py 2006-06-22 13:50:42 UTC (rev 68790)
+++ zc.form/trunk/src/zc/form/field.py 2006-06-22 20:41:20 UTC (rev 68791)
@@ -189,6 +189,17 @@
... print "Not a field"
...
Not a field
+
+ Binding a union field also takes care of binding the contained fields:
+
+ >>> context = object()
+ >>> bound_f = f.bind(context)
+ >>> bound_f.context is context
+ True
+ >>> bound_f.fields[0].context is context
+ True
+ >>> bound_f.fields[1].context is context
+ True
"""
interface.implements(interfaces.IUnionField)
@@ -204,7 +215,17 @@
field.__name__ = "unioned_%02d" % ix
self.fields = tuple(fields)
super(Union, self).__init__(**kw)
-
+
+ def bind(self, object):
+ clone = super(Union, self).bind(object)
+ # We need to bind the fields too
+ clone_fields = []
+ for field in clone.fields:
+ clone_fields.append(field.bind(object))
+ clone_fields = tuple(clone_fields)
+ clone.fields = clone_fields
+ return clone
+
def validField(self, value):
"returns first valid field, or None"
for field in self.fields:
More information about the Checkins
mailing list