Date: Thu Jun 30 13:48:00 2005
New Revision: 2682
The old technique for installing COMKit has broken now that we
are using new-style classes. I replaced it with a different
technique that seems to work OK.
--- Webware/trunk/COMKit/__init__.py (original)
+++ Webware/trunk/COMKit/__init__.py Thu Jun 30 13:48:00 2005
@@ -21,36 +21,36 @@
sys.coinit_flags = 0
- # See if the win32 extensions are available
+ # Get the win32 extensions
- # Create a base class for a COM-enabled app server.
- class COMEnabledAppServer:
- def initThread(self):
- # This must be called at the beginning of any thread that uses COM
- import pythoncom
- # Invoke superclass's initThread. This enables multiple plug-ins
- # to each have their own initThread get called.
- def delThread(self):
- # Invoke superclass's delThread. This enables multiple plug-ins
- # to each have their own delThread get called.
- # This must be called at the end of any thread that uses COM
- import pythoncom
- # We mix-in the COMEnabledAppServer, but it's a reverse mix-in:
- # Make COMEnabledAppServer inherit the current app server's class
- COMEnabledAppServer.__bases__ = (appServer.__class__,)
- # Make the current app server point to COMEnabledAppServer
- appServer.__class__ = COMEnabledAppServer
+ # Grab references to the original initThread and delThread bound
+ # methods, which we will replace
+ original_initThread = appServer.initThread
+ original_delThread = appServer.delThread
+ # Create new versions of initThread and delThread which will call the
+ # old versions
+ def new_initThread(self):
+ # This must be called at the beginning of any thread that uses COM
+ # Call the original initThread
+ def new_delThread(self):
+ # Call the original delThread
+ # Uninitialize COM
+ # Replace the initThread and delThread with our new versions, for
+ # this instance of the appserver only
+ import new
+ appServer.initThread = new.instancemethod(new_initThread, appServer, appServer.__class__)
+ appServer.delThread = new.instancemethod(new_delThread, appServer, appServer.__class__)
print 'COM has been enabled.'
- # Note: Python makes "plugging in" possible.