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  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
PYTHON

Windows Programming in Python
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 26
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    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
     

       

    PYTHON ARTICLES

    - Tuples and Other Python Object Types
    - The Dictionary Python Object Type
    - String and List Python Object Types
    - Introducing Python Object Types
    - Mobile Programming using PyS60: Advanced UI ...
    - Nested Functions in Python
    - Python Parameters, Functions and Arguments
    - Python Statements and Functions
    - Statements and Iterators in Python
    - Sequences and Sets in Python
    - Python Expressions and Operators
    - Dictionaries, Variables and Statements in Py...
    - Data Types in Python
    - The Python Language
    - SSH with Twisted





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek