home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import win32com.server.util as win32com
- import pythoncom
-
- class SimpleConnection:
-
- def __init__(self, coInstance = None, eventInstance = None, eventCLSID = None, debug = 0):
- self.cp = None
- self.cookie = None
- self.debug = debug
- if coInstance is not None:
- self.Connect(coInstance, eventInstance, eventCLSID)
-
-
-
- def __del__(self):
-
- try:
- self.Disconnect()
- except pythoncom.error:
- pass
-
-
-
- def _wrap(self, obj):
- useDispatcher = None
- if self.debug:
- dispatcher = dispatcher
- import win32com.server
- useDispatcher = dispatcher.DefaultDebugDispatcher
-
- return win32com.server.util.wrap(obj, useDispatcher = useDispatcher)
-
-
- def Connect(self, coInstance, eventInstance, eventCLSID = None):
-
- try:
- oleobj = coInstance._oleobj_
- except AttributeError:
- oleobj = coInstance
-
- cpc = oleobj.QueryInterface(pythoncom.IID_IConnectionPointContainer)
- if eventCLSID is None:
- eventCLSID = eventInstance.CLSID
-
- comEventInstance = self._wrap(eventInstance)
- self.cp = cpc.FindConnectionPoint(eventCLSID)
- self.cookie = self.cp.Advise(comEventInstance)
-
-
- def Disconnect(self):
- if self.cp is not None:
- if self.cookie:
- self.cp.Unadvise(self.cookie)
- self.cookie = None
-
- self.cp = None
-
-
-
-