I have a content component that has a property that is a dictionary,
the keys of which are objects (content components themselves). The
values are lists of strings. I've tried implementing this a couple
different ways, but each time I restart, the dictionary comes up
empty.


Hi Alan,

Worked for me in a quick interactive test..


demo.py
=======
from persistent import Persistent

class Demo(Persistent):
    def __init__(self):
        self.d = {}


>>> import transaction
>>> from demo import Demo
>>> from zope.app.folder import Folder
>>>
>>> # get the root object using debugger
>>>
>>> root[u'test_folder'] = f = Folder()
>>> f[u'test_object'] = ob = Demo()
>>> ob.d
{}
>>> ob.d[Demo()] = ['1','2']
>>> ob.d[Demo()] = ['a','b']
>>> from pprint import pprint
>>> pprint(ob.d
{demo.Demo object at 0x415796ec>: ['a', 'b'],
 demo.Demo object at 0x41579f2c>: ['1', '2']}
>>> ob._p_changed = True
>>> transaction.commit()
>>> Ctrl-D

Connect to zope again...

>>>
>>> # get the root object using debugger
>>> ob = root[u'test_folder'][u'test_object']
>>> from pprint import pprint
>>> pprint(ob.d)
{<well3.demo.Demo object at 0x4155466c>: ['a', 'b'],
 <well3.demo.Demo object at 0x415796ec>: ['1', '2']}
>>>


_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to