AW: [Zope3-Users] AW: AW: z3c.form and subforms in an AddForm?
Roger Ineichen
dev at projekt01.ch
Mon Jun 18 07:21:12 EDT 2007
Hi Mats
> Betreff: Re: [Zope3-Users] AW: AW: z3c.form and subforms in
> an AddForm?
>
>
> Roger,
>
> Thanks again for trying to help me out. I think I'm having
> some registration issues that I'm not sure what to do with.
> Using the example you posted I receive the following error:
>
> Traceback (most recent call last):
> Module zope.publisher.publish, line 133, in publish
> result = publication.callObject(request, obj)
> Module zope.app.publication.zopepublication, line 161, in callObject
> return mapply(ob, request.getPositionalArguments(), request)
> Module zope.publisher.publish, line 108, in mapply
> return debug_call(obj, args)
> - __traceback_info__: <security proxied
> z3c.pagelet.zcml.RestaurantAddForm instance at 0x02E33F90>
> Module zope.publisher.publish, line 114, in debug_call
> return obj(*args)
> Module z3c.formui.layout, line 34, in __call__
> self.update()
> Module metrod.restaurant.browser.restaurant, line 33, in update
> self.address.update()
> Module z3c.form.form, line 134, in update
> super(Form, self).update()
> Module z3c.form.form, line 83, in update
> self.updateWidgets()
> Module metrod.restaurant.browser.address, line 25, in updateWidgets
> self.widgets.update()
> Module z3c.form.field, line 245, in update
> widget.update()
> Module z3c.form.widget, line 96, in update
> value = zope.component.getMultiAdapter(
> Module z3c.form.datamanager, line 48, in get
> context = self.field.interface(context)
> TypeError: ('Could not adapt', None, <InterfaceClass
> metrod.restaurant.interfaces.IAddress>)
This means there is no context in the AddressAddForm.
You missed ignoreContext=True in the setupWidgets method.
> My forms look like this:
>
> browser/restaurant.py
>
> class RestaurantAddForm(AddFormLayoutSupport, form.EditForm):
> """Add form"""
>
> template = None
> layout = None
> contentName = None
> label = u'Add Restaurant'
> prefix = u'restaurant'
>
> fields = field.Fields(IRestaurant)
>
> def updateWidgets(self):
> self.widgets = component.getMultiAdapter((
> self, self.request, self.getContent()), IWidgets)
> self.widgets.ignoreContext = True
> self.widgets.update()
>
> def update(self):
> self.address = AddressAddForm(None, self.request)
> self.address.update()
> super(RestaurantAddForm, self).update()
>
> browser/address.py
>
> class AddressAddForm(AddFormLayoutSupport, form.EditForm):
> template = None
> layout = None
> contentName = None
> label = u'Address'
>
> fields = field.Fields(IAddress)
> prefix = u'address'
>
> def updateWidgets(self):
> self.widgets = component.getMultiAdapter((
> self, self.request, self.getContent()), IWidgets)
> self.widgets.ignoreRequest = True
> self.widgets.update()
You missed in the AddressAddForm ``self.widgets.ignoreContext = True``
And take more care about the super classes. you are suing a EditForm
as base. Same in the RestaurantAddForm.
Regards
Roger Ineichen
_____________________________
END OF MESSAGE
More information about the Zope3-users
mailing list