Python
  Home arrow Python arrow Page 2 - Windows Programming in Python
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PYTHON

Windows Programming in Python
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 24
    2006-04-19

    Table of Contents:
  • Windows Programming in Python
  • What is COM?
  • Calling COM components from Python
  • COM Programming in Python, in the Real World

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Windows Programming in Python - What is COM?


    (Page 2 of 4 )

    Component Object Model is a software architecture that allows software to be built from binary components. This implies that if COM objects are used in building software, they can communicate with each other without knowing each other's details. Even if the components are implemented in different languages, they can communicate with each other.

    At the lowest level, COM is all about interfaces. It leaves the implementation details up to the class that implements the interface. In short, COM makes a clear distinction between the interfaces and the objects that implement these interfaces. When working with COM it is important to understand how COM views certain common terms. They are:

    1. Interface

    2. Objects

    3. Globally Unique Identifier

    4. COM Libraries

    All of these together provide a framework-like implementation to COM specifications. Let's look at the details to understand how these provide the framework-like implementation.

    1. Interface:

    By definition, "Interface is a class in which all the methods are pure virtual methods." When seen in accordance with the COM specification, interface is a strongly typed "contract" between software components. This contract provides a small but useful set of methods. In essence COM treats interfaces as the definition of an expected behavior and responsibilities. One of the main characteristic features of a COM interface is that if new methods are added to the interface, it becomes a new interface.

    The convention for naming interfaces is that the names are preceded with an "I." The best example is the IUnkown interface. It is defined by COM to implement some essential functionality. All COM components are required to implement the IUnkown interface. The specialty of the IUnkown interface is that by implementing it, COM objects can control their own lifespan. Thus through the IUnknown interface, COM provides the basis of a likely framework.

    2. Objects:

    In OOPs, an object is an instance of a class. But in COM, an object is a piece of compiled code that provides some specific service to rest of the software system. As described under Interface above, the COM objects (or components as they are generally called) support the IUnknown interface. The main difference between simple objects and COM components is that unlike other objects, one COM component can never access another COM component directly. The access must be through interface pointers.

    COM defines many interfaces. One of the implemented interfaces is the IDispatch interface. It allows COM components to be called from scripting environments.  Also, the components that implement IDispatch are known as automation components. The reason is that by using such a COM object, OLE automation can be implemented. As I said in the Interface section, each component has a unique identifier. It is known as GUID.

    3. Globally Unique Identifier:

    Globally Unique Identifier, or GUID for short, is a 128 bit integer that is guaranteed to be unique across all the COM components used the world over and created in the past or present. The human readable names are provided just for convenience, and their scope is local, which prevents accidental connections to wrong interfaces or methods. When a GUID refers to the class, it is known as CLSID, whereas GUID referring to the interfaces are called IID. The GUIDs can be created using tools such as uuidgen, provided by Microsoft.

    4. COM Libraries:

    COM library is a system component that provides the mechanics of COM as well as encapsulating the leg work associated with launching COM components and communicating with other components. Generally when a COM component has to be launched, the CLSID of the component is passed to the COM library, which in turn uses the CLSID to look up the associated server code in the registry and launches the component using either CoRegisterClassFactory or DllGetClassFactory.

    That's about all the overview about COM. The above described four aspects form the basis for any type of COM application. In the next section I will focus on how Python maps the COM techniques into its domain.

    More Python Articles
    More By A.P.Rajshekhar


       · COM is the basis of almost all of the window application. In one way or another we...
       · Seems easy. But I had a problem...this is the output I got from...
       · Which version of MS Office are you using
       · You have forgotten "Documents"Correct it has to be:...
     

       

    PYTHON ARTICLES

    - SSH with Twisted
    - Mobile Programming in Python using PyS60: UI...
    - Python: Count on It
    - Python Strings: Spinning Yarns
    - Python: More Fun with Strings
    - Python: Stringing You Along
    - Python Operators
    - Bluetooth Programming in Python: Network Pro...
    - Python Sets
    - Python Conditionals, Lists, Dictionaries, an...
    - Python: Input and Variables
    - Introduction to Python Programming
    - Mobile Programming in Python using PyS60: Ge...
    - Bluetooth Programming using Python
    - Finishing the PyMailGUI Client: User Help To...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway