Whoa, really bad line breaks, here is the pastbin link http://zope3.pastebin.com/867518
David, zc.table makes rendering html tables more programmatic. --- [EMAIL PROTECTED] wrote: > Thanks for the direction, Gary. :) > > Getting a Choice field working in doctests was quite > a > challenge. It now fails as only as a zc.table > FieldColumn. I'm including the relevant doctests and > tests.py > > I apologize in advance for the verbose post. :) > > Kevin Smith > > > > > File > "/root/temp/zc.table-0.6/src/zc/table/fieldcolumn.txt", > line 131, in fieldcolumn.txt > Failed example: > print formatter() > Exception raised: > Traceback (most recent call last): > File > "/root/temp/zc.table-0.6/eggs/zope.testing-3.0-py2.4.egg/zope/testing/doctest.py", > line 1348, in __run > compileflags, 1) in test.globs > File "<doctest fieldcolumn.txt[19]>", line 1, > in > ? > print formatter() > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 66, in __call__ > return '\n<table%s>\n%s</table>\n%s' % ( > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 75, in renderContents > return ' <thead%s>\n%s </thead>\n > <tbody>\n%s </tbody>\n' % ( > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 98, in renderRows > return ''.join([self.renderRow(item) for > item > in self.getItems()]) > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 106, in renderRow > return ' <tr%s>\n%s </tr>\n' % ( > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 110, in renderCells > return ''.join( > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 114, in renderCell > return ' <td%s>\n %s\n </td>\n' % > ( > File > "/root/temp/zc.table-0.6/src/zc/table/table.py", > line > 121, in getCell > return column.renderCell(item, self) > File > "/root/temp/zc.table-0.6/src/zc/table/fieldcolumn.py", > line 162, in renderCell > return self.getRenderWidget( > File > "/root/temp/zc.table-0.6/src/zc/table/fieldcolumn.py", > line 114, in getRenderWidget > widget = self.getInputWidget(item, > formatter) > File > "/root/temp/zc.table-0.6/src/zc/table/fieldcolumn.py", > line 105, in getInputWidget > widget = component.getMultiAdapter((field, > request), iface) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/_api.py", > line 101, in getMultiAdapter > adapter = queryMultiAdapter(objects, > interface, name, context=context) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/_api.py", > line 114, in queryMultiAdapter > return > sitemanager.queryMultiAdapter(objects, > interface, name, default) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/registry.py", > line 206, in queryMultiAdapter > return self.adapters.queryMultiAdapter( > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/interface/adapter.py", > line 482, in queryMultiAdapter > result = factory(*objects) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/app/form/browser/itemswidgets.py", > line 44, in ChoiceInputWidget > IInputWidget) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/_api.py", > line 101, in getMultiAdapter > adapter = queryMultiAdapter(objects, > interface, name, context=context) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/_api.py", > line 114, in queryMultiAdapter > return > sitemanager.queryMultiAdapter(objects, > interface, name, default) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/component/registry.py", > line 206, in queryMultiAdapter > return self.adapters.queryMultiAdapter( > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/interface/adapter.py", > line 482, in queryMultiAdapter > result = factory(*objects) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/app/form/browser/itemswidgets.py", > line 315, in __init__ > super(ItemsEditWidgetBase, > self).__init__(field, vocabulary, request) > File > "/root/temp/zc.table-0.6/parts/zope3/src/zope/app/form/browser/itemswidgets.py", > line 83, in __init__ > assert field.context is not None > AssertionError > > > > > == fieldcolumn.txt == > > > >>> import re > >>> from zope import schema, interface > >>> class IContact(interface.Interface): > ... name = schema.TextLine(title=u'Name') > ... email = schema.TextLine( > ... title=u'Email Address', > ... > constraint=re.compile('[EMAIL PROTECTED]([.]\w+)+$').match) > ... salutation = schema.Choice( > ... title=u'Salutation', > ... values = ['Mr','Ms'], > ... ) > > >>> class Contact: > ... interface.implements(IContact) > ... def __init__(self, id, name, email, > salutation): > ... self.id = id > ... self.name = name > ... self.email = email > ... self.salutation = salutation > > >>> contacts = ( > ... Contact('1', 'Bob Smith', > '[EMAIL PROTECTED]', > 'Mr'), > ... Contact('2', 'Sally Baker', > '[EMAIL PROTECTED]', 'Ms'), > ... Contact('3', 'Jethro Tul', > '[EMAIL PROTECTED]', 'Mr'), > ... Contact('4', 'Joe Walsh', > '[EMAIL PROTECTED]', > 'Mr'), > ... ) > > >>> from zope.formlib import form > > > > >>> class MyForm(form.EditForm): > ... form_fields = form.Fields( IContact ) > > Sanity test > > >>> from zope.publisher.browser import > TestRequest > >>> request = TestRequest() > >>> myform = MyForm(contacts[0], request) > >>> print myform() > Name > <input class="textType" id="form.name" > name="form.name" size="20" type="text" value="Bob > Smith" /> > Email Address > <input class="textType" id="form.email" > name="form.email" size="20" type="text" > value="[EMAIL PROTECTED]" /> > Salutation > <div> > === message truncated === _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users