interest in DelayedResult?

From: Robin Dunn [mailto:robin@alldunn.com]
Sent: August 4, 2006 1:12 PM

Oliver Schoenborn wrote:
> This is now easier to use, IMO. Feedback welcome.

The eventType parameter in DelayedResult.ByEvent should be
named eventBinder or something similar. (eventType is the
name used for the numeric event IDs.)

So, just to make sure I understand: the Threads example in the demo has
the following code:

   # This creates a new Event class and a EVT binder function
   (UpdateBarEvent, EVT_UPDATE_BARGRAPH) = wx.lib.newevent.NewEvent()
   ...
   evt = UpdateBarEvent(...)
   wx.PostEvent(self.win, evt)
   ...
   self.Bind(EVT_UPDATE_BARGRAPH, self.OnUpdate)

This suggests the first item in the pair returned from NewEvent() is the
new event class, and the second item is the binder. In this case the
byEvent() and ByEvent.__init__() take an event class, not a binder; they
just care to know what type of event to generate, and who gets it, and
leaves the binding up to the caller (because the DelayedResult.byEvent()
could be used many times, yet you only want to bind once).

Do I have the terminology inverted?

Would it make sense to allow appending of listeners instead
of just prepending?

No. The unit test takes shortcuts that make sense for black-box testing,
but are otherwise misleading in terms of use of the module. I will
include better docs and add a test that can be used as an example.

The ByClass and ByEvent names aren't very intuitive for what
they do, but I'm not able to think of anything else at the
moment to suggest...

I doubt they would ever be used directly by the user. Instead, consider:

  import DelayedResult
  ...
  delayedResult1 = DelayedResult.byCall(callable)
  delayedResult2 = DelayedResult.byEvent(evtHandler, evtClass)
  assert isinstance(delayedResult1, DelayedResult.DelayedResult)
  assert isinstance(delayedResult2, DelayedResult.DelayedResult)

In first case you are creating a delayed result that will be transmitted
by calling your callable, vs in second case by generating an event that
is given to your handler object.

Oliver

DelayedResult.py (12.4 KB)

···

-----Original Message-----

Oliver Schoenborn wrote:

The eventType parameter in DelayedResult.ByEvent should be named eventBinder or something similar. (eventType is the name used for the numeric event IDs.)

So, just to make sure I understand: the Threads example in the demo has
the following code:

   # This creates a new Event class and a EVT binder function
   (UpdateBarEvent, EVT_UPDATE_BARGRAPH) = wx.lib.newevent.NewEvent()
   ...
   evt = UpdateBarEvent(...)
   wx.PostEvent(self.win, evt)
   ...
   self.Bind(EVT_UPDATE_BARGRAPH, self.OnUpdate)

This suggests the first item in the pair returned from NewEvent() is the
new event class, and the second item is the binder.

Correct.

In this case the
byEvent() and ByEvent.__init__() take an event class, not a binder; they
just care to know what type of event to generate, and who gets it, and
leaves the binding up to the caller (because the DelayedResult.byEvent()
could be used many times, yet you only want to bind once).

I see.

Do I have the terminology inverted?

No, it's just that there is already something different called eventType, so I think that it should be renamed eventClass or something like that. Also I was confused by the docstring for ByEvent which said that the eventType parameter was "typically the second item in the pair returned by wx.lib.newevent.NewEvent()" when it is actually the first.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!