[Zope] BoboPOS and nested dictionaries

Jeff Bauer jeffbauer@bigfoot.com
Sun, 14 Feb 1999 11:34:10 -0600


Hi all.

I'm having a slight problem with BoboPOS and nested dictionaries.
BoboPOS 2.0.2.  The problem is that changes to a nested dictionary 
attribute are not being saved.

Here are two of my workarounds, discovered just this morning.

    # Dictionary deletions not saved.  Workaround: Delete
    # the dictionary item, make a shallow copy to a new
    # dict, and reassign the object attribute to it.

    del self.treatment_orders[treatment]
    d = {}
    for k,v in self.treatment_orders.items():
        d[k] = v
    self.treatment_orders = d

Next, to assign a dictionary sub-element, I would usually
perform the following kind of operation:

    self.treatment_orders[treatment]['FREQ'] = frequency

However, the changes aren't saved unless I borrow Python's
deepcopy feature, and reassign the attribute to the dict
copy.

    from copy import deepcopy
    d = deepcopy(self.treatment_orders)
    d[treatment]['FREQ'] = frequency
    self.treatment_orders = d

Before I spend more time on this issue, I'd be interested
in learning if there are any known problems with nested
dictionaries in BoboPOS.  Environment: Python 1.5.2a2, linux2

Best regards,

Jeff Bauer
Rubicon, Inc.