> You missed in the AddressAddForm ``self.widgets.ignoreContext = True``

I see that I missed that statement, it was late on a sleepless night, but I
couldn't get this out of my head.  In any case, I've changed my code to
match the example you gave in the repository.  I also have the templates
defined in the view instead of through zcml as you have in the tests.


class RestaurantAddForm(form.EditForm):
    """Add form"""
    fields = field.Fields(IRestaurant).select('name', 'description')
    template = viewpagetemplatefile.ViewPageTemplateFile('')
    prefix = u'restaurant'
    def updateWidgets(self):
        self.widgets = component.getMultiAdapter((
            self, self.request, self.getContent()), IWidgets)
        self.widgets.ignoreContext = True
    def update(self):
        self.address = AddressAddForm(None, self.request)
        super(RestaurantAddForm, self).update()


class AddressAddForm(form.EditForm):
    fields = field.Fields(IAddress)
    template = viewpagetemplatefile.ViewPageTemplateFile('')
    prefix = u'address'
    def updateWidgets(self):
        self.widgets = component.getMultiAdapter((
            self, self.request, self.getContent()), IWidgets)
        self.widgets.ingoreContext = True


    permission="zope.Public" />

I believe those matches your example exactly but I still get the adaption
error when the form should be displayed.

Traceback (most recent call last):
  Module zope.publisher.publish, line 133, in publish
    result = publication.callObject(request, obj)
  Module, 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 0x02EE17D0>
  Module zope.publisher.publish, line 114, in debug_call
    return obj(*args)
  Module z3c.form.form, line 139, in __call__
  Module, line 31, in update
  Module z3c.form.form, line 134, in update
    super(Form, self).update()
  Module z3c.form.form, line 83, in update
  Module, line 21, in updateWidgets
  Module z3c.form.field, line 245, in 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>)

Am I forgetting some configuration on my forms?  I have not configured
anything for AddressAddForm could that be the issue?

> And take more care about the super classes. you are suing a EditForm 
> as base. Same in the RestaurantAddForm.

Not sure I'm understanding this, your example used EditForm without any
thought on superclasses.

Again thanks for all your time and effort, I really appreciate this.

Mats Nordgren

PS. Would there be a chance you could include the car/owner example in the
z3c.formdemo package?

Zope3-users mailing list

Reply via email to