Hello, I'm new to Zope, and using Zope 3.3. I have managed to get a
simple site running.

I am having trouble getting the web interface to let me edit an object
that contains a list, where the type of values in the list, is an
interface that also holds a list.  I can’t get this “list inside a list”
setup to work correctly.

In my example, I have a Person object that contains a list of PersonInfo
objects, where each PersonInfo contains a list of names.

When I enter the view for Person (based on EditForm), it displays an
edit form as I would expect. However, when I try to add a PersonInfo to
the list via the interface, an exception is raised:

“TypeError: iteration over non-sequence” 

(The full traceback is over 6 pages long, so I won’t post it, but it
does mention “sequencewidget” many times).

I've tried some variations to narrow down the problem:

*If I change PersonInfo to hold just a string instead of a list, it

*If I change Person to hold just a single PersonInfo instead of a list,
it works!

* Therefore, it seems like my Zope site is set up OK, but for some
reason Lists of objects with Lists raise an exception.
Am I missing something? Maybe I have to write some custom widget to get
around this? Is this possibly a known problem?

The code:

********** People.py *****************

class IPersonInfo(interface.Interface):
    names = schema.List(

class IPerson(interface.Interface):
    ID = schema.TextLine(
        description=u'Persons ID code')

    the_list = schema.List(
        title=u"PersonInfo list",

class PersonInfo(persistent.Persistent):    
    def __init__(self):
        self.names = persistent.list.PersistentList()

def PersonInfoWidget(context,obj,request):
        return ObjectWidget(context, request, PersonInfo)

class Person(persistent.Persistent):    
    ID = "1-2-3"   
    def __init__(self):
        self.the_list = persistent.list.PersistentList()

class AutoEditView(form.EditForm):
    form_fields = form.Fields(IPerson)

class PersonInfoView(form.EditForm):
    form_fields = form.Fields(IPersonInfo)

********** end People.py *****************

configure.zcml doesn’t do anything unusual, it sets up the views to use
my custom widgets and sets up the edit views and security. 

Regards and thanks for your help!
  Daniel M

http://www.fastmail.fm - Send your email first class

Zope3-users mailing list

Reply via email to