PyXR

c:\python24\lib\site-packages\win32 \ com \ client \ CLSIDToClass.py



0001 """Manages a dictionary of CLSID strings to Python classes.
0002 
0003 Primary use of this module is to allow modules generated by
0004 makepy.py to share classes.  @makepy@ automatically generates code
0005 which interacts with this module.  You should never need to reference
0006 this module directly.
0007 
0008 This module only provides support for modules which have been previously
0009 been imported.  The gencache module provides some support for loading modules
0010 on demand - once done, this module supports it...
0011 
0012 As an example, the MSACCESS.TLB type library makes reference to the
0013 CLSID of the Database object, as defined in DAO3032.DLL.  This
0014 allows code using the MSAccess wrapper to natively use Databases.
0015 
0016 This obviously applies to all cooperating objects, not just DAO and
0017 Access.
0018 """
0019 mapCLSIDToClass = {}
0020 
0021 def RegisterCLSID( clsid, pythonClass ):
0022         """Register a class that wraps a CLSID
0023         
0024         This function allows a CLSID to be globally associated with a class.
0025         Certain module will automatically convert an IDispatch object to an
0026         instance of the associated class.
0027         """
0028         
0029         mapCLSIDToClass[str(clsid)] = pythonClass
0030         
0031 def RegisterCLSIDsFromDict( dict ):
0032         """Register a dictionary of CLSID's and classes.
0033         
0034         This module performs the same function as @RegisterCLSID@, but for
0035         an entire dictionary of associations.
0036         
0037         Typically called by makepy generated modules at import time.
0038         """
0039         try:
0040                 mapCLSIDToClass.update(dict)
0041         except AttributeError: # Python 1.4?
0042                 for clsid, pythonClass in dict.items():
0043                         mapCLSIDToClass[clsid] = pythonClass
0044                 
0045 def GetClass(clsid):
0046         """Given a CLSID, return the globally associated class.
0047         
0048         clsid -- a string CLSID representation to check.
0049         """
0050         return mapCLSIDToClass[clsid]
0051         
0052 def HasClass(clsid):
0053         """Determines if the CLSID has an associated class.
0054         
0055         clsid -- the string CLSID to check
0056         """
0057         return mapCLSIDToClass.has_key(clsid)
0058 

Generated by PyXR 0.9.4
SourceForge.net Logo