[Grok-dev] schema.Object

Souheil CHELFOUH trollfot at gmail.com
Wed Jul 21 05:19:10 EDT 2010


The traceback says it tries to find a widget to display in your form,
for the Object field.
An Object field doesn't have any widget. It doesn't automatically read
the schema to try and display what you need.
You will have to do it yourself, and create a widget.

2010/7/21 Sascha Boch <sascha.boch at gmx.de>:
> Hi Christian,
>
> sure, I also changed the code a bit so that it is now a list of objects:
>
> URL: http://localhost:8020/Foo/admin
> File
> '/root/.buildout/eggs/Paste-1.7.2-py2.6.egg/paste/evalexception/middleware.py',
> line 306 in respond
>   app_iter = self.application(environ, detect_start_response)
> File
> '/root/.buildout/eggs/zope.app.wsgi-3.6.1-py2.6.egg/zope/app/wsgi/__init__.py',
> line 59 in __call__
>   request = publish(request, handle_errors=handle_errors)
> File
> '/root/.buildout/eggs/zope.publisher-3.12.3-py2.6.egg/zope/publisher/publish.py',
> line 134 in publish
>   result = publication.callObject(request, obj)
> File '/root/.buildout/eggs/grok-1.1.1-py2.6.egg/grok/publication.py', line
> 89 in callObject
>   return super(ZopePublicationSansProxy, self).callObject(request, ob)
> File
> '/root/.buildout/eggs/zope.app.publication-3.10.2-py2.6.egg/zope/app/publication/zopepublication.py',
> line 205 in callObject
>   return mapply(ob, request.getPositionalArguments(), request)
> <Foo.app.FooEditForm object at 0x26fd990>
> File
> '/root/.buildout/eggs/zope.publisher-3.12.3-py2.6.egg/zope/publisher/publish.py',
> line 109 in mapply
>   return debug_call(obj, args)
> File
> '/root/.buildout/eggs/zope.publisher-3.12.3-py2.6.egg/zope/publisher/publish.py',
> line 115 in debug_call
>   return obj(*args)
> File
> '/root/.buildout/eggs/grokcore.formlib-1.5-py2.6.egg/grokcore/formlib/components.py',
> line 90 in __call__
>   self.update_form()
> File
> '/root/.buildout/eggs/grokcore.formlib-1.5-py2.6.egg/grokcore/formlib/components.py',
> line 62 in update_form
>   super(GrokForm, self).update()
> File '/root/.buildout/eggs/zope.formlib-4.0-py2.6.egg/zope/formlib/form.py',
> line 750 in update
>   errors, action = handleSubmit(self.actions, data, self.validate)
> File '/root/.buildout/eggs/zope.formlib-4.0-py2.6.egg/zope/formlib/form.py',
> line 693 in handleSubmit
>   errors = default_validate(action, data)
> File '/root/.buildout/eggs/zope.formlib-4.0-py2.6.egg/zope/formlib/form.py',
> line 730 in validate
>   return (getWidgetsData(self.widgets, self.prefix, data)
> File '/root/.buildout/eggs/zope.formlib-4.0-py2.6.egg/zope/formlib/form.py',
> line 346 in getWidgetsData
>   data[name] = widget.getInputValue()
> File
> '/root/.buildout/eggs/zope.formlib-4.0-py2.6.egg/zope/formlib/sequencewidget.py',
> line 165 in getInputValue
>   sequence = self._type(self._generateSequence())
> File
> '/root/.buildout/eggs/zope.formlib-4.0-py2.6.egg/zope/formlib/sequencewidget.py',
> line 227 in _generateSequence
>   widget = self._getWidget(i)
> File
> '/root/.buildout/eggs/zope.formlib-4.0-py2.6.egg/zope/formlib/sequencewidget.py',
> line 105 in _getWidget
>   (field, self.request), IInputWidget)
> File
> '/root/.buildout/eggs/zope.component-3.9.1-py2.6.egg/zope/component/_api.py',
> line 111 in getMultiAdapter
>   raise ComponentLookupError(objects, interface, name)
> ComponentLookupError: ((<zope.schema._field.Object object at 0x27994d0>,
> <zope.publisher.browser.BrowserRequest instance
> URL=http://localhost:8020/Foo/admin>), <InterfaceClass
> zope.formlib.interfaces.IInputWidget>, u'')
>
> class IFooField(interface.Interface):
>     name = schema.TextLine(title=u'Name', required = True)
>     format = schema.Choice(title=u'Field Format', required = True, values =
> ['Text', 'Date', 'Number'])
>
> class IFoo(interface.Interface):
>     title=schema.TextLine(title=u'Title',required=True)
>     description=schema.TextLine(title=u'Description',required=False)
>     data_fields= schema.List(title=u'Fields', required = False, unique =
> True,
>         value_type = schema.Object(title=u'Field', required = False, schema
> = IFooField))
>
> class Foo(grok.Application, grok.Container):
>     grok.implements(IFoo)
>     title = u'Foobar'
>     description = u''
>
> class FooEditForm(grok.EditForm):
>     grok.context(Foo)
>     grok.name('admin')
>
>     form_fields = grok.AutoFields(Foo)
>     template = grok.PageTemplateFile('custom_edit_form.pt')
>
> Many thanks again!
>
> Sascha
>
>
>
> --
> Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
> Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev
>
>


More information about the Grok-dev mailing list