[Zope3-Users] Problems in sequences of custom objects display view
ksmith93940-dev at yahoo.com
ksmith93940-dev at yahoo.com
Fri Oct 13 19:48:00 EDT 2006
I'm looking into formlib and display widgets. If anyone on the list has an example, I'd love to see it. The following Objects of List example works perfectly for edit view. For the display view it shows the AddressBook schema fine, but shows the Person schema edit form. I've googled all day, but have failed to come up with anything. Any help on this is appreciated. Thanks.
Kevin Smith
PS: Stephen, thanks for your feedback on mapDictToSchema
browser.py
person_widget = CustomWidgetFactory(ObjectWidget, Person)
persons_widget = CustomWidgetFactory(ListSequenceWidget, subwidget=person_widget)
class EditFormView(form.EditForm):
form_fields = form.Fields(IAddressBook, render_context=True)
form_fields['persons'].custom_widget = persons_widget
class DisplayFormView(form.DisplayForm):
form_fields = form.Fields(IAddressBook, for_display=True)
form_fields['persons'].custom_widget = persons_widget
app.py
class IPerson( interface.Interface ):
first = schema.TextLine( title=u"firstname" )
last = schema.TextLine( title=u"lastname" )
class Person( Persistent ):
interface.implements( IPerson )
def __init__( self, first='', last='' ):
self.first, self.last = first, last
first= ''
last= ''
class IAddressBook( interface.Interface ):
title = schema.TextLine( title=u'Title', required=False )
persons = schema.List( title=u'Persons',
value_type=schema.Object( IPerson, title=u'person' ),
required=False )
class AddressBook( Persistent ):
interface.implements( IAddressBook )
def __init__( self, title="My Address Book" ):
# create a default title
self.title=title
title = ''
# don't forget to make lists persistent
persons = PersistentList()
More information about the Zope3-users
mailing list