Where is/are the Bind-ings list(s) stored?

When a widget does a self.widget.Bind(event...) where is that binding
stored? Is it in the wx.App (inherits from EvtHander) or the widget's
event handler object or the eventloop MainLoop itself, some event
filter list? Does the widget retain some list of what Bindings where
done to it? Where is this binds or bindings list?

I have a custom widget that does a PostEvent of a few custom events to
itself.

EVT_NODE_CHECK_STATE; a user may click a button or enter data or a
span of time may have lapsed where the message gets posted.

Other widgets that may (OR MAY NOT BE) be bound to it and handlers
will react to it, like compare against archive (a non-widget effec)
and a statusbar update.
self.sb.Bin(EVT_NODE_CHECK_STATE, self.OnCheckState, )

However I plan to throttle this event (much like EVT_IDLE is)
depending on bursts of traffic. The event may get sent in bursts alot
or not at all randomly during the day. If say the admin UI is off and
nodes are in a freeze state. There may be times when the external
widgets and handlers are not even running and so not even bound.

If nothing is bound to my widget for any one specific event type I
don't want to post the event to itself, the widget (evthandler
actually). So if noone is bound, don't postevent to self.

However how do I test if anyone is bound to widget's self for a
certain event type?

Oh here is perhaps a better way to express it. Lets try with a
wx.Timer subclass.

# Totally fake code
class CrazyActiveThing(wx.Timer):
    def __init__...
    def Notify(self):
        if len(self.GetBindings() == 0:
            return False
        else:
            wx.PostEvent(wx.EVT_TIMER, self.OnTimer, self)
cats = []
for i in range(1000):
   activething = CrazyActiveThing(GetNextActivitlyLevel())
   activething.Start(random.random(10000))
   cats.append(activething)

That's hyperbolie of activity
That will generate alot of events. Some active things will not be
active at all. So I don't want them posting events.

The actual evthander, a schedualer, is not random but what it
processes can be anywhere from either a longrunning process to a
failed at start process.

I'm going to look into doing other ways too, but I'm still curious to
know where any and all "bindings" (not events and not handlers) are
stored/referenced.

When a widget does a self.widget.Bind(event...) where is that binding
stored? Is it in the wx.App (inherits from EvtHander) or the widget's
event handler object or the eventloop MainLoop itself, some event
filter list? Does the widget retain some list of what Bindings where
done to it? Where is this binds or bindings list?

The dynamic event table is stored inside the C++ object that is the "self" in a "self.Bind()" statement. Unfortunately there is no access to it from outside of the class so I can't expose it to Python other than for connecting and disconnecting event bindings.

However how do I test if anyone is bound to widget's self for a
certain event type?

You'll probably have to override Bind and Unbind in your classes and track the info yourself.

Or you can avoid using events for your messages and use something like pubsub instead.

···

On 10/25/11 4:08 PM, DevPlayer wrote:

--
Robin Dunn
Software Craftsman

I didn't think of overriding (Un)Bind. I can work with. I'll likely go
with overriding Bind. I've been avoiding pubsub even as cool as it
looks. I'm playing with Yami4 atm and pubsub and yami have many
similaries like publishers and listeners. All that does is make class
names and flags and stuff start to look alike.

Funny thing about pubsub is I'd feel like I'd be cheating with it.
Funny right? It feels like I'm using a library that's abandoning the
OSes event system for a another event system a couple of layers up
call stack. I keep thinking, "Boy all that extra pointer-to-pointer-to-
pointer-pointer on top of what's there aready i'd be adding. But on
the opposite side I wanted to evaluate yami against gevent+gunicorn
against twisted and even pubsub. I'm in my evaluate, research, learn
and measure phase on this though.

By the way, are there any issues with thread safety by overriding
(Un)Bind?. I've been interpreting from other forums that PostEvent is
thread safe. And on the note of thread safety, the class i'm
subclassing is evthandler.

I presume there's no difference between evthandlers and "gui" widgets
regarding thread safety... meaning use CallAfter or PostEvent or
AddPendingEvent to send to thread and Queue and like (or pubsub) to
send back from threads, even to Evthandlers. (question in the form of
a statement)

···

On Oct 25, 10:19 pm, Robin Dunn <ro...@alldunn.com> wrote:

You'll probably have to override Bind and Unbind in your classes and
track the info yourself.

Or you can avoid using events for your messages and use something like
pubsub instead.
Robin Dunn

You'll probably have to override Bind and Unbind in your classes and
track the info yourself.

Or you can avoid using events for your messages and use something like
pubsub instead.
Robin Dunn

I didn't think of overriding (Un)Bind. I can work with. I'll likely go
with overriding Bind. I've been avoiding pubsub even as cool as it
looks. I'm playing with Yami4 atm and pubsub and yami have many
similaries like publishers and listeners. All that does is make class
names and flags and stuff start to look alike.

Funny thing about pubsub is I'd feel like I'd be cheating with it.
Funny right? It feels like I'm using a library that's abandoning the
OSes event system for a another event system a couple of layers up
call stack.

Well for custom events there is no OS code involved at all, it's all in the wx layers. So you wouldn't be totally cheating. :wink:

By the way, are there any issues with thread safety by overriding
(Un)Bind?. I've been interpreting from other forums that PostEvent is
thread safe. And on the note of thread safety, the class i'm
subclassing is evthandler.

I presume there's no difference between evthandlers and "gui" widgets
regarding thread safety... meaning use CallAfter or PostEvent or
AddPendingEvent to send to thread and Queue and like (or pubsub) to
send back from threads, even to Evthandlers. (question in the form of
a statement)

Bind itself is probably okay from alternate threads, but yeah the way the handler functions are called and the ruls about not modifying UI objects from alternate threads still apply.

···

On 10/25/11 7:51 PM, DevPlayer wrote:

On Oct 25, 10:19 pm, Robin Dunn<ro...@alldunn.com> wrote:

--
Robin Dunn
Software Craftsman

DevPlayer wrote:

Oh here is perhaps a better way to express it. Lets try with a
wx.Timer subclass.
...
That's hyperbolie of activity
That will generate alot of events. Some active things will not be
active at all. So I don't want them posting events.

The overhead of an unhandled event is tiny. You are guilty of premature
optimization.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

I'm ok with that.