[Grok-dev] schema.Object

Sascha Boch sascha.boch at gmx.de
Wed Jul 21 05:11:02 EDT 2010


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20100721/44b36924/attachment.html 


More information about the Grok-dev mailing list