[omniORB] ILU to omniORB (lengthy)

Thomas Lockhart lockhart at fourpalms.org
Fri Sep 26 15:23:09 BST 2003


> 3.  omniidl's python backend makes some assumptions....
>     The omniidl stubber drops a file Module_idl.py and creates Module
>     and Module_POA packages, all in the current directory. The
>     __init__.py in each package import module_idl, which only works if
>     "the current directory" is the current directory at runtime, or
>     "the current directory" is on PYTHONPATH. Neither of these options
>     is particularly good for my client application.

but there are other options...

>     Presently I'm doing some hijinx where I os.chdir to the "current
>     directory" prior to importing the Module package, then os.chdir
>     back to the working directory after the import takes. This appears
>     to work just fine, but I find it a little concerning. Does anyone
>     have a better solution?

The omniidl backend by default builds files appropriate for installation 
as a "library". So generate the files, then install them where you want. 
You can look at the omniORBpy IDL make system for hints on how to 
pre-compile the python code etc for a good installation. When I first 
started building python apps, I mucked around with options for omniidl 
to vary the output behavior. But ended up deciding that it wasn't really 
fixing my "problem"...

At the top of your app, before importing your application-specific 
files, put something like

import sys, string
sys.path = string.split(string.strip("@YOURPATHS@"), ":") + sys.path
import yourModule
...

where @YOURPATHS@ is an autoconf substitution variable or some other 
special path. With this technique you don't need to manipulate the 
external PYTHONPATH. If you really have no idea where a client app was 
installed, perhaps python offers a way to determine the path to the 
currently-running app, and you can base the rest of your path 
information off of that. I haven't researched that one.

hth

                         - Tom





More information about the omniORB-list mailing list