Tom Dossis wrote:
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']} >>>
This will only work with immutable objects such as string. Otherwise, you will need a persistent dict or a OOBTree or you have to set self._p_changed manually.
Regards, Dominik
begin:vcard fn:Dominik Huber n:Huber;Dominik email;internet:[EMAIL PROTECTED] tel;work:++41 56 534 77 30 x-mozilla-html:FALSE version:2.1 end:vcard
_______________________________________________ Zope3-users mailing list [email protected] http://mail.zope.org/mailman/listinfo/zope3-users
