I'm having this stripped-down use case.

class IToy(Interface):
    name = TextLine(title=u"Toy")

class Toy(Persistent):
    name = FieldProperty(IToy['name'])

class IGadget(Interface):
    name = TextLine(title=u"Gadget")

class Gadget(Persistent):
    name = FieldProperty(IGadget['name'])

    def __init__(self,toy):
        super(Person, self).__init__(self)
        self.name = toy.name

class IBaby(Interface):
    name = TextLine(title=u"Name")
    toys = List(title=u"toys",value_type=Object(schema=IToy,title=u"toy")

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

class Baby(Persistent):
    name = FieldProperty(IBaby['name'])
    toys = FieldProperty(IBaby['toys'])

class Person(Persistent):
    name = FieldProperty(IBaby['name'])
    gadgets = FieldProperty(IPerson['gadgets'])

    def __init__(self,baby):
        super(Person, self).__init__(self)
        self.name = baby.name

When IBaby is at the end of its workflow, it should be replaced by an

So I've made a view that creates a new IPerson based on data from the
old IBaby, and replaces the baby with the person on its container.

class BabyView(BrowserView):

    def growup(self):
        baby = self.context
        parentfolder = baby.__parent__
        id = baby.__name__
        person = Person(baby)
        del parentfolder[id]
        parentfolder[id] = person

It works, and I see the new object with the name I passed over from IBaby.

The trouble is when I add the following to growup()

        person.gadgets = [ Gadget(toy) for toy in baby.toys ]

This creates the gadgets (one per each toy) but the Gadget.name
attributes, altough being created, are not persisted.

The @@edit and @@index views show the Gadget.name attributes are
missing. I did not @@introspect the gadgets because I cannot traverse to

Is this the right place for a PersistentList? Using it in growup() and
__init__ in place of FieldProperty does not make it work.

Zope3-users mailing list

Reply via email to