[Zope3-Users] AW: AW: z3c.form and subforms in an AddForm?

Mats Nordgren mats at ronin-group.org
Mon Jun 18 04:20:03 EDT 2007


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>)

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()

I have them registered like this:

  <z3c:pagelet
    name="addRestaurant.html"
    for="zope.app.container.interfaces.IContainer"
    class=".restaurant.RestaurantAddForm"
    layer="metrod.app.layer.IMetroDBrowserLayer"
    permission="zope.Public" />
  
  <z3c:template
    template="restaurant.pt"
    for=".restaurant.RestaurantAddForm"
    layer="metrod.app.layer.IMetroDBrowserLayer" />

  <z3c:template
    template="address.pt"
    for=".address.AddressAddForm"
    layer="metrod.app.layer.IMetroDBrowserLayer" />

Thanks again for all your time and help,

Mats Nordgren
> Hi Mats
> 
>>  Betreff: Re: [Zope3-Users] AW: z3c.form and subforms in an AddForm?
>>  
>>  
>>  Roger,
>>  
>>  Thanks for your reply.  I'm still having problems getting 
>>  this to work.
>>  
>>  I'm not sure I am supposed to use a BaseForm, Form, AddForm, 
>>  or what, for the sub-item.  I'm not sure how to register it 
>>  in zcml to not get adaption errors when I run it.
>>  
>>  Would there be any chance to have the example with the "car" 
>>  and "owner" in the Sub-Form doc test included in the formdemo 
>>  package.  I'd like to see that included with "Class I" and 
>>  "Class II" for both AddForm and EditForm since it is such a 
>>  common use case.
>>  
>>  Perhaps I'm just dense, but I still have problems converting 
>>  doc tests into an actual working zope instance.  The formdemo 
>>  package was a god send to get a simple addform working since 
>>  I had no idea you needed to use the IFormLayer.  Using the 
>>  demo that was no longer a problem.
>>  
>>  Again thanks for all your help.
> 
> Ok, the context less demo is in revision 76745.
> 
> svn://svn.zope.org/repos/main/z3c.form/trunk/src/z3c/form/subform.txt
> 
> line 489 - 608
> 
> Regards
> Roger Ineichen

-- 
View this message in context: http://www.nabble.com/z3c.form-and-subforms-in-an-AddForm--tf3929436.html#a11171577
Sent from the Zope3 - users mailing list archive at Nabble.com.



More information about the Zope3-users mailing list