[python-win32] FrameMaker programming via FrameMaker API COM? OLE? What?

Jens B. Jorgensen jens.jorgensen at tallan.com
Fri Jul 18 13:36:28 EDT 2003


You can probably do all of this without creating a C extension module. 
You'd use the win32 extensions COM support. As long as the type library 
is automation compatible it will work. You'll first probably want to 
generate a COM wrapper library with <python 
dir>/Lib/site-packages/win32com/client/makepy.py. This script will throw 
up a GUI that will allow you to select the type library for the 
FrameMaker API. By default the script will generate the wrapper library 
as a module named by the type library's GUID, version, and LCID and 
store it in Lib/site-packages/win32com/gen_py/. You'd then access it in 
your script with:

from win32com.client import gencache
FM = gencache.EnsureModule(<guid>, <LCID>, <major ver #>, <minor ver #>)

And then FM will be a python module. For example I use the VSS COM API with:
VSS = gencache.EnsureModule('{783CD4E0-9D54-11CF-B8EE-00608CC9A71F}', 0, 
5, 1)

The sticking point here if of course that you need to know the guid, 
version, and LCID. This is not a big deal really though. You can use the 
OLE View tool that comes with Visual Studio to lookup the library by 
name under the Type Libraries tree and then when you select it in the 
right pane you'll see something like:

TypeLib
  + {783CD4E0-9D54-11CF-B8EE-00608CC9A71F}
      + 5.1 = Microsoft SourceSafe 6.0 Type Library
         + 0
             + win32 = <path>
          ...

The version is there (5.1) and the LCID is the integer under that.

Then just follow the API's documentation. The identifier will be the 
same. You may find minor weirdness where objects have "properties" that 
take params. Sometimes for these python has to generate get and set 
methods to handle these with generated names. Should you hit something 
like this just look at the generated wrapper .py and you should be able 
to see what wrapper methods have been created. Other than that the type 
lib Enums will be under <module>.constants

Good luck!

Brian Mahoney wrote:

>I'm biting the bullet and looking at wrapping the
>C-language FrameMaker API in Python. Adobe FrameMaker 
>Windows documentation describes a COM session where a
>client can connect to the running FrameMaker session
>and use the full FrameMaker API library to control FM.
> 
>
>However, before I start wrapping the API, my first
>Python extension, I would like to understand the
>FrameMaker COM/OLE, at least see if I can do the
>initial connection via existing Python modules. 
>Everything, including the session connection is done
>through the API, so I learn nothing from that
>documentation. My previous OLE experience started and
>ended with the first version of OLE for 16-bit Windows
>so I am not up on current OLE/COM terminology.
>
>The Visual Studio OLE/COM object viewer, under "All
>Objects" shows me a 32-bit FrameMaker API
>InProcServer32 = ole32.dll
>LocalServer32  = ...FrameMaker.exe /Automation /iconic
>/nosplash
>The most interesting interfaces are
>IFrameMakerSession0 and IFrameMakerSession1
>They list a CLSID with an
>IFrameMakerSession0_PSFactory
>with an InprocServer32 = ...\afmfdk.dll
>
>Does this tell me what kind of server I have for
>FrameMaker or is it only telling me stuff about the
>FrameMaker API client, and what I do in Python to
>expose any interface?
>
>
>__________________________________
>Do you Yahoo!?
>SBC Yahoo! DSL - Now only $29.95 per month!
>http://sbc.yahoo.com
>
>_______________________________________________
>Python-win32 mailing list
>Python-win32 at python.org
>http://mail.python.org/mailman/listinfo/python-win32
>  
>

-- 
Jens B. Jorgensen
jens.jorgensen at tallan.com

"With a focused commitment to our clients and our people, we deliver value through customized technology solutions"  





More information about the Python-win32 mailing list