why not using form.Form to derive from :

class MyForm(form.Form):
    form_fields = form.Fields(IOrder, omit_readonly=True)

Register this as a page and you are up and running.


Vinny wrote:

Platform details:

# pkg_info | grep zope
zope-3.3.0          An object-based web application platform
# uname -a
FreeBSD 6.2-RELEASE #1:
# python
Python 2.4.3 (#2, Dec 26 2006, 16:13:56)
[GCC 3.4.4 [FreeBSD] 20050518] on freebsd6

Using IDLE 1.1.3

Using instructions from:

With code straight out of it typed into the IDLE editor, saved
as and run using the F5 command:

=================== 8< ========
from zope import interface, schema
class IOrder(interface.Interface):
    identifier = schema.Int(title=u"Identifier", readonly=True)
    name = schema.TextLine(title=u"Name")
    min_size = schema.Float(title=u"Minimum size")
    max_size = schema.Float(title=u"Maximum size")
    now = schema.Datetime(title=u"Now", readonly=True)

from zope.formlib import form
class MyForm:
    form_fields = form.Fields(IOrder)

#This sets up a set of form fields from the interface, IOrder.

print len(MyForm.form_fields)

print [w.__name__ for w in MyForm.form_fields]

class MyForm:
    form_fields = form.Fields(IOrder, omit_readonly=True)

    def __init__(self, context, request):
        self.context, self.request = context, request

    def __call__(self, ignore_request=False):
        widgets = form.setUpWidgets(
            self.form_fields, 'form', self.context, self.request,
        return '\n'.join([w() for w in widgets])

from zope.publisher.browser import TestRequest
request = TestRequest()
print MyForm(None, request)() # doctest: +NORMALIZE_WHITESPACE

Saving and running this gives:
=================== RESTART ========================

['identifier', 'name', 'min_size', 'max_size', 'now']

Traceback (most recent call last):
  File "/usr/local/www/Zope3/mv/lib/python/hello/", line 33, in
    print MyForm(None, request)() # doctest: +NORMALIZE_WHITESPACE
  File "/usr/local/www/Zope3/mv/lib/python/hello/", line 28, in
  File "/usr/local/www/Zope3/lib/python/zope/formlib/", line
256, in setUpWidgets
  File "/usr/local/www/Zope3/lib/python/zope/component/", line
103, in getMultiAdapter
    raise ComponentLookupError(objects, interface, name)
ComponentLookupError: ((<zope.schema._bootstrapfields.TextLine object
at 0x8cf53cc>, <zope.publisher.browser.TestRequest instance
URL=>), <InterfaceClass>, u'')

Sigh.  Am I jinxed?  I've been trying to learn zope 3 for six
months now.  All I want is to be able to make a form from an
interface and display the dang thing.  Is that too much to
ask?  /rant

Does anyone know what's going wrong?  Do I need to upgrade

Thanks in advance.


Zope3-users mailing list

Reply via email to