[Zope3-Users] ++skin++Boston bug

Marco Mariani marco at sferacarta.com
Wed May 24 01:19:38 EDT 2006


dev at projekt01.ch wrote:
> Hi Marco
> 
> [...]
>> /me guesses this has to do with using the widget_row macro 
>> inside another widget_row, thus trying to render 
>> <tr><td><tr><td>....</td></tr></td></tr> and the browser 
>> closes the fieldset, td and tr when it encounters a <td><tr> sequence.
> 
> There is something wrong if you get a widget_row inside a widget_row.
> What did you register that this nested widget/widget get happen?

Here it is:



---------------------
person/configure.zcml
---------------------
<configure xmlns="http://namespaces.zope.org/zope" i18n_domain="person" >


  <!-- PERSON -->

  <interface
    interface=".IPerson"
    type="zope.app.content.interfaces.IContentType"/>

  <class class=".Person">
    <factory
        id="person.Person"
        description="Person"
        />
    <require
        permission="zope.View"
        interface=".IPerson"
        />
    <require
        permission="zope.ManageContent"
        set_schema=".IPerson"
        />
  </class>


  <!-- FAMILY -->

  <interface
    interface=".IFamily"
    type="zope.app.content.interfaces.IContentType"
    />

  <class class=".Family">
    <factory
        id="person.Family"
        description="Family"
        />
    <require
        permission="zope.View"
        interface=".IFamily"
        />
    <require
        permission="zope.ManageContent"
        set_schema=".IFamily"
        />
  </class>


  <include package=".browser" />

</configure>




------------------
person/__init__.py
------------------
from zope.interface import Interface, implements
from zope.schema import TextLine, Object, List, Choice, Field
from persistent import Persistent


class IPerson(Interface):
    name = TextLine(title=u'Name')


class Person(Persistent):
    implements(IPerson)

    name = ''


class IFamily(Interface):

    mother = Object(title=u'Mother',
                    schema=IPerson)

    father = Object(title=u'Father',
                    schema=IPerson)


class Family(Persistent):
    implements(IFamily)

    mother = ''
    father = ''




-----------------------------
person/browser/configure.zcml
-----------------------------
<configure
    xmlns:zope="http://namespaces.zope.org/zope"
    xmlns="http://namespaces.zope.org/browser">


  <page
    class=".forms.FamilyAdd"
    name="AddFamily.html"
    permission="zope.ManageContent"
    for="zope.app.container.interfaces.IAdding"
    />

  <addMenuItem
    factory="person.Family"
    title="Family"
    description="New Family"
    permission="zope.ManageContent"
    view="AddFamily.html"
    />

</configure>




-----------------------
person/browser/forms.py
-----------------------
from zope.formlib.form import Fields, AddForm, EditForm
from person import Person, IPerson, Family, IFamily
from zope.app.form.browser import ObjectWidget
from zope.app.form import CustomWidgetFactory


class FamilyAdd(AddForm):
    form_fields = Fields(IFamily)
    form_fields['mother'].custom_widget =
CustomWidgetFactory(ObjectWidget, Person)
    form_fields['father'].custom_widget =
CustomWidgetFactory(ObjectWidget, Person)

    def create(self, data):
        family = Family()
        family.mother = data['mother']
        family.father = data['father']
        return family







More information about the Zope3-users mailing list