Hi everybody,
a bit of a general architecture/best practice question. Say you want to keep
in sync an ElementTree with a separate tree structure, one that is parallel
but does not have the exact same nodes and yet needs to be informed and
updated whenever a change in the ElementTree occurs. ElementTree supports
custom elements and I guess it wouldn't be too difficult to override the
standard methods of an element to do something before or after any change.
-However-, I understand that ElementProxies cannot store instance-level data
as the instances are not persistent and are garbage collected more or less
as soon as they are no longer referenced somewhere. So, what I'm wondering
is, how do I tell a method of a custom element what object in the parallel
structure to inform whenever a change arises? I guess one way would be to
store at -class level- (or where else?) a dictionary mapping custom
ElementProxies instances to nodes of the parallel structure. In so doing
whenever a custom method is executed it can get hold of the parallel
structure. Is that a reasonable way to do it or are there better ones?
Manu