[pywin32-checkins] pywin32/com/win32com/server dispatcher.py,1.4,1.5
OLD project page for the Python extensions for Windows
                
                Brought to you by:
                
                    mhammond
                    
                
            
            
        
        
        
    | 
      
      
      From: Mark H. <mha...@us...> - 2004-09-07 02:16:50
      
     | 
| Update of /cvsroot/pywin32/pywin32/com/win32com/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9688 Modified Files: dispatcher.py Log Message: * Support writing exception to a logging module object instead of stdout. * Support for GetTypeInfo and GetTypeInfoCount * "deprecate" the pywin.debugger dispatcher - no one uses it and it just upsets py2exe Index: dispatcher.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/server/dispatcher.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dispatcher.py 8 Nov 2003 00:38:44 -0000 1.4 --- dispatcher.py 7 Sep 2004 02:16:40 -0000 1.5 *************** *** 9,12 **** --- 9,13 ---- from win32com.server.exception import IsCOMServerException from win32com.util import IIDToInterfaceName + import win32com class DispatcherBase: *************** *** 22,25 **** --- 23,29 ---- def __init__(self, policyClass, object): self.policy = policyClass(object) + # The logger we should dump to. If None, we should send to the + # default location (typically 'print') + self.logger = getattr(win32com, "logger", None) def _CreateInstance_(self, clsid, reqIID): *************** *** 48,51 **** --- 52,67 ---- self._HandleException_() + def _GetTypeInfo_(self, index, lcid): + try: + return self.policy._GetTypeInfo_(index, lcid) + except: + self._HandleException_() + + def _GetTypeInfoCount_(self): + try: + return self.policy._GetTypeInfoCount_() + except: + self._HandleException_() + def _GetDispID_(self, name, fdex): try: *************** *** 103,115 **** # If not a COM exception, print it for the developer. if not IsCOMServerException(): ! traceback.print_exc() # But still raise it for the framework. reraise() def _trace_(self, *args): ! for arg in args[:-1]: ! print arg, ! print args[-1] ! class DispatcherTrace(DispatcherBase): """A dispatcher, which causes a 'print' line for each COM function called. --- 119,138 ---- # If not a COM exception, print it for the developer. if not IsCOMServerException(): ! if self.logger is not None: ! self.logger.exception("pythoncom server error") ! else: ! traceback.print_exc() # But still raise it for the framework. reraise() def _trace_(self, *args): ! if self.logger is not None: ! record = " ".join(map(str, args)) ! self.logger.debug(record) ! else: ! for arg in args[:-1]: ! print arg, ! print args[-1] ! class DispatcherTrace(DispatcherBase): """A dispatcher, which causes a 'print' line for each COM function called. *************** *** 125,128 **** --- 148,159 ---- return DispatcherBase._GetIDsOfNames_(self, names, lcid) + def _GetTypeInfo_(self, index, lcid): + self._trace_("in _GetTypeInfo_ with index=%d, lcid=%d\n" % (index, lcid)) + return DispatcherBase._GetTypeInfo_(self, index, lcid) + + def _GetTypeInfoCount_(self): + self._trace_("in _GetTypeInfoCount_\n") + return DispatcherBase._GetTypeInfoCount_(self) + def _Invoke_(self, dispid, lcid, wFlags, args): self._trace_("in _Invoke_ with", dispid, lcid, wFlags, args) *************** *** 168,173 **** def __init__(self, policyClass, object): DispatcherTrace.__init__(self, policyClass, object) ! import win32traceutil # Sets up everything. ! print "Object with win32trace dispatcher created (object=%s)" % `object` --- 199,206 ---- def __init__(self, policyClass, object): DispatcherTrace.__init__(self, policyClass, object) ! if self.logger is None: ! # If we have no logger, setup our output. ! import win32traceutil # Sets up everything. ! self._trace_("Object with win32trace dispatcher created (object=%s)" % `object`) *************** *** 191,196 **** """ def __init__(self, policyClass, ob): ! import pywin.debugger pywin.debugger.brk() # DEBUGGER Note - You can either: # * Hit Run and wait for a (non Exception class) exception to occur! --- 224,234 ---- """ def __init__(self, policyClass, ob): ! # No one uses this, and it just causes py2exe to drag all of ! # pythonwin in. ! #import pywin.debugger pywin.debugger.brk() + print "The DispatcherWin32dbg dispatcher is deprecated!" + print "Please let me know if this is a problem." + print "Uncomment the relevant lines in dispatcher.py to re-enable" # DEBUGGER Note - You can either: # * Hit Run and wait for a (non Exception class) exception to occur! *************** *** 203,207 **** # Save details away. typ, val, tb = exc_info() ! import pywin.debugger, pywin.debugger.dbgcon debug = 0 try: --- 241,245 ---- # Save details away. typ, val, tb = exc_info() ! #import pywin.debugger, pywin.debugger.dbgcon debug = 0 try: |