John Anderson wrote:
Maybe
we should get rid collection notifications and use monitors instead
since notification don't do what we need -- what do you think?
I think monitors and notifications each have their place, and I'd be
really against getting rid of notifications - I think notifications are
a fine solution to this problem, and their asynchronicity is important
for having a responsive app.
(though it would be nice if the fact that one is asynchronous and one
is synchronous wasn't a decision that we had to make. In my case, I'd
probably prefer an asynchronous monitor, but using the detail view's
approach (a collection with one item) seems like overkill to watch just
one attribute)
In the end I'm going to use a monitor for the case of color - its
really the right tool for the job in this case and the synchronicity
shouldn't be too much a problem
Alec
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