Maybe we should get rid collection notifications and use monitors
instead since notification don't do what we need -- what do you think?
John
Andi Vajda wrote:
John/Ted -
So right now the way notifications work is if any items in a collection
get modified/etc, then a notification goes out to subscribers.
In the case of color, I'm actually interested in getting notified when
the 'color' attribute on the collection itself, not a member of the
collection, is changed. I can change it via a menu right now, but the
calendar code doesn't know the color changed, so it doesn't know to
redraw.
what would you guys think about making notifications fire for both the
collection items, as well as changes to the collection itself?
Don't use notifications for that, use a monitor.
For example:
class AlecsItem(Item):
def aColorChangedSomewhere(self, op, item, attribute):
if op == 'set' and isCollection(item) and attribute == 'color':
print 'gosh, a colored collection changed to', item.color
Attach the monitor:
Monitors.attach(alecsItemInstance, 'aColorChangedSomewhere', 'set',
'color')
Et voila. Monitors are persistent so you only need to set this up once.
Collection notifications, as implemented today, are a UI-only device
fired from the wx event loop's OnIdle() method. They are asynchronous
and rather heavy as they are broadcast all subscribers of a set,
indiscriminately.
Monitors are synchronous and broadcast only to items monitoring the
given op/attribute combination.
Andi..
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
Open Source Applications Foundation "Dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/dev