Developing a COM server in Python is easier than in any other language. If the process is broken down into steps there are primarily two steps, which are developing the class and annotating the class with attributes. Furthermore, in the first step you must decide on which model the class must be based. Developing the class
The COM interface, Python delegate pattern is the most commonly used. The reason for this is the ability to develop the class first. In the pattern of a COM base class, pure Python subclass, a base class has to be defined and exposed as a COM server. The methods in the base class perform no tasks. The base class works as a COM interface. Then a sub class, which implements the base class, has to be developed; this class provides the actual services. In other words a class that implements the base class performs the tasks. This pattern is most appropriate when designing a class whose main function is to be used from COM and not from Python. Now let's look at a pure Python base class, COM subclass pattern. It is in a way the opposite of the previous pattern. Here, the existing COM class is inherited from a Python base class. The COM class can be differentiated by the the attributes used to annotate the class, which will be discussed shortly. Finally, let's examine the COM interface, Python delegate pattern. In this case, the COM interface is defined. The class that defines the COM interface has variables internal to it that point to the pure Python counterpart. The Python counterpart is known as the delegate. The methods of class that represent the COM interface translate their arguments, return values as needed, and forward them to the delegate. Let's take the third pattern as an example. For the sake of the example, suppose there is a BookSet class that implements the methods of the COM interface. Now if the third pattern is applied to define a COM interface, it would look like this:
blog comments powered by Disqus |