I'd like to create a reusable schema-fragment so that content images are always
explicitly associated with alt text. I created an interface like this:
class INazImage(form.Schema):
"""
Just a NamedBlobImage with a built-in alt field
"""
image = NamedBlobImage(title=_(u"Image"))
alt = schema.TextLine(
title=_(u"Image Alternative"),
description=image_alt_description,
)
and I'm trying to use it like this, for example:
class IContact(form.Schema):
"""
A single contact entry
"""
image = schema.Object(
title=_(u"Contact Image"),
schema=INazImage,
)
name = schema.TextLine(title=_(u"Contact Name"))
title = schema.TextLine(title=_(u"Contact Title"))
department = schema.TextLine(title=_(u"Contact Department"))
email = schema.TextLine(title=_(u"Contact Email"))
phone = schema.TextLine(title=_(u"Contact Phone"))
notes = schema.Text(
title=_(u"Contact Notes"),
description=_(u"Notes, Other Positions, etc"),
)
class IContactPage(ICommonModulesSchema):
"""
A page that lists the contacts for a department.
"""
body = RichText(title=_(u"Body"), required=False)
contacts = schema.List(
title=_(u"Contacts"),
value_type=schema.Object(schema=IContact),
min_length=1,
)
The form appears to render well; however, as soon as I try to edit the list of
contacts in it, I get a 'Could not adapt' TypeError. I'd appreciate any
assistance in getting past this.
2010-10-16 19:07:03 ERROR Zope.SiteErrorLog 1287270423.920.870024682414
http://localhost:8080/Plone/kss_z3cform_inline_validation
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 <wrapper>, line 5, in wrapper
Module kss.core.actionwrapper, line 236, in apply
Module plone.app.z3cform.kss.validation, line 47, in validate_input
Module plone.z3cform.fieldsets.extensible, line 59, in update
Module plone.z3cform.patch, line 30, in GroupForm_update
Module z3c.form.group, line 125, in update
Module z3c.form.form, line 132, in updateWidgets
Module z3c.form.field, line 276, in update
Module z3c.form.browser.multi, line 61, in update
Module z3c.form.browser.widget, line 70, in update
Module z3c.form.widget, line 88, in update
Module z3c.form.widget, line 383, in set
Module z3c.form.widget, line 352, in updateWidgets
Module z3c.form.widget, line 341, in applyValue
Module z3c.form.object, line 253, in set
Module z3c.form.object, line 207, in updateWidgets
Module z3c.form.object, line 56, in _validate
Module z3c.form.object, line 153, in toFieldValue
TypeError: ('Could not adapt', {'image': <plone.namedfile.file.NamedBlobImage
object at 0x5d77770>, 'alt': u'a'}, <InterfaceClass
naz.basetypes.modules.naz_image.INazImage>)
Best wishes,
Michael A. Smith
Web & Digital / Academic Technologies Manager
Nazareth College
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers