<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Yes, looks really nicely done, I'm just wondering wether you actually
tested this or not (and if it worked of course)?<br>
<br>
<div class="moz-signature"><big><font face="Verdana" size="-2"><big><!-- SGT -->Mortis<br>
European Tactical Battlefield Forces<!--<a href="http://www.theartofwarfare.net">The Art Of Warfare</a> - BF<br>
The Gryphons--></big></font></big></div>
<br>
<br>
Forrest Thiessen schreef:
<blockquote cite="mid42E44469.9020304@cyberscapearena.com" type="cite">
  <pre wrap="">Thanks for the suggestion. . . it turns out this won't work, though, for
a complicated reason:

When a handler is registered, the BF2 Python host gets a reference to
the callback function. If you change the function by any normal method
(for example, setting the attribute that contains the reference to it to
point to a different function), the event system in the Python host
still has it's ORIGINAL reference to the ORIGINAL callback--and that's
where the callback will go.  That's why I wanted to unregister the
handler: because as long as it remains registered, the callbacks go to
the same place, no matter what you do.  Even if you somehow managed to
nuke the original handler so that it looks like it's gone, Python keeps
track of objects via reference counting, and it would *know* that a
reference still existed somewhere to the original handler, and so would
not let it be destroyed.

I eventually figured out a byzantine way around the problem, at least
for my purposes:
    
<a class="moz-txt-link-freetext" href="http://bf2.fun-o-matic.org/index.php/Cookbook:Dynamically_Changing_an_Event_Handler">http://bf2.fun-o-matic.org/index.php/Cookbook:Dynamically_Changing_an_Event_Handler</a>
The method I came up with recognizes that I can't do anything about the
original handler function object, but I *can* swap out the code object
inside of it. It doesn't result in the handler becoming unregistered,
but what I was really after was a way to replace a standard handler with
one of my own, anyway, so this fits the bill.

If you really, really wanted to get an effect identical to
unregistering, you could just make the replacement function in the
recipie implement nothing but a "pass" statement.

--Forrest (aka "Woody")




  </pre>
  <blockquote type="cite">
    <pre wrap="">Date: Sat, 23 Jul 2005 23:34:59 +0200
From: "Einar S. Ids?" <a class="moz-txt-link-rfc2396E" href="mailto:esi@itk.ntnu.no">&lt;esi@itk.ntnu.no&gt;</a>
Subject: Re: [bfprog] Unregistering Handlers
To: Battlefield Programming <a class="moz-txt-link-rfc2396E" href="mailto:bfprog@lists.matureasskickers.net">&lt;bfprog@lists.matureasskickers.net&gt;</a>
Message-ID: <a class="moz-txt-link-rfc2396E" href="mailto:42E2B803.9060205@itk.ntnu.no">&lt;42E2B803.9060205@itk.ntnu.no&gt;</a>
Content-Type: text/plain; charset=ISO-8859-1

Like Steven said, this method don't seem to exist. I don't know what
technique Steven uses in his Modmanager, though I am looking forward to
seeing his work, but, depending on why you need to unregister the event
handler, you might get by by simply reassigning the function being
called to do absolutely nothing? It would still incur the time to call,
obviously, but just let it pass/return immediately.

You could use a simple dummy-function for this which takes nothing but
key/val arguments, so that each and every function you want to
cancel/unregister can be redirected to this single dummy-function.

Einar

    </pre>
  </blockquote>
  <pre wrap=""><!---->
_______________________________________________
BFProg mailing list
<a class="moz-txt-link-abbreviated" href="mailto:BFProg@lists.matureasskickers.net">BFProg@lists.matureasskickers.net</a>
<a class="moz-txt-link-freetext" href="http://lists.matureasskickers.net/mailman/listinfo/bfprog">http://lists.matureasskickers.net/mailman/listinfo/bfprog</a>


  </pre>
</blockquote>
</body>
</html>