gnumed-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnumed-devel] python orb interface


From: sjtan
Subject: [Gnumed-devel] python orb interface
Date: Tue, 30 Dec 2003 02:41:51 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030313

Well, I'm glad to report that omniORBpy can access the open-emeds pids server. ( is it GPL ?)

After starting off with trashing my system by accidently deleting glibc when I was trying to get ORBit2 to work, some of hours of massaging the idl files for PersonIdService.idl
finally got it working.
Here's a brief rundown:
1. installed omniORB and omniORBPy .4.0.3
- needed to load python-2.2.2-devel rpm for the include files for omniORB to compile -needed to copy recursively /usr/local/lib/python2.2/site-packages/* to /usr/lib/python2.2/site-packages/*
on Mandrake .

2. used the tutorial in the doc directory in omniORBPy to get a hang of their corba implementation.

3. ran the omniORB nameServer using the parameters for the pids nameserver.
       omniNames -start 5002 -logdir /home/sjtan/omniLog

4. ran the pids server. It connects to the omni name server without much hassle.

5. (optional)used a modified client that finds the pids server via the NameService instead of
an ior.file to verify NameService works.

6. copied the idl files in open-emeds/src/interfaces/corbamed/idl into a test directory ( need to do a recursive copy to copy the AbbreviatedIncludes directory as well). - the tricky bits here is the include path of PersonIdService.idl has a base of ../../ and finds corbamed/idl/"included_idl_file.xxx" , and this was fixed by by making a corbamed/idl directory inside the base idl directory, and recursively copying the AbbreviatedIncludes directory there. Also copy the
NamingAuthority.idl to corbamed/idl.
mkdir -p corbamed/idl

cp -R AbbreviatedIncludes  corbamed/idl/
cp NamingAuthority.idl corbamed/idl

7. Edit the PersonIdService.idl and wrap the declarations inside the statement
      module PersonIdService  {
            // .. declarations
       };

- this little bit kept me busy for half a day , as to why I could get an undifferentiated Corba Object
   in python but was unable to Narrow it into a IdentificationComponent.
Printing a IdentificationComponent.__dict__ finally showed that class IdentificationComponent has a property '_NP_RepositoryId': 'IDL:omg.org/IdentificationComponent:1.0' whereas the CORBA object.__dict__ showed '_NP_RepositoryId': 'IDL:omg.org/PersonIdService/IdentificationComponent:1.0'

8. run
   omniidl -b python  -nc PersonIdService.idl
to check for any path errors. Notes: * The -nc option lets omniidl accept case-sensitive declarations such as
               "Profile profile;"
* the -I . option should be left out, otherwise the idl generator will generate new stubs for CosNaming (because they are in the AbbreviatedIncludes) , which interferes with the real omniORB CosNaming packages.

9.  attached is a python session showing how a python client can now access
the pids server.
The session was run in the same directory as the idl files directory, where omnidl was run
to generate the python stubs.






















address@hidden idl]$ python
Python 2.2.2 (#2, Feb  5 2003, 10:40:08)
[GCC 3.2.1 (Mandrake Linux 9.1 3.2.1-5mdk)] on linux-i386
Type "help", "copyright", "credits" or "license" for more information.
>>> import CosNaming, CORBA, omniORB
>>> orb = CORBA.ORB_init( ["-", "-ORBInitRef", 
>>> "NameService=corbaloc:iiop:address@hidden:5002/NameService"])
>>> print orb.list_initial_services()
['NameService', 'RootPOA', 'POACurrent']
>>> o1 = orb.resolve_initial_references("NameService")
>>> ctx = o1._narrow(CosNaming.NamingContextExt)
>>> l=[]
>>> for x in "us/nm/state/doh/Pilot".split("/"):
...   l.append(CosNaming.NameComponent(x, "") )
...
>>> o2 = ctx.resolve(l)
>>> import PersonIdService
>>> idComponent = o2._narrow(PersonIdService.IdentificationComponent)
>>> print idComponent.__methods__
['_get_domain_name', '_get_component_name', '_get_supported_traits', 
'_get_identify_person', '_get_profile_access', '_get_sequential_access', 
'_get_identity_access', '_get_id_mgr', '_get_correlation_mgr', 
'_get_naming_context', '_get_trader_components', 'get_supported_properties', 
'_is_a', '_non_existent', '_is_equivalent', '_get_interface', '_hash', 
'_narrow']
>>> traits = idComponent._get_supported_traits()
>>> for x in traits:
...   print x.__dict__
...
{'read_only': 1, 'trait': 'PIDS/InternalId', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'PIDS/DuplicateIds', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'PIDS/CorrelatedIds', 'mandatory': 0, 'searchable': 1}
{'read_only': 1, 'trait': 'PIDS/ExternalIds', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/PatientName', 'mandatory': 1, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/MothersMaidenName', 'mandatory': 0, 
'searchable': 1}
{'read_only': 0, 'trait': 'HL7/DateTimeofBirth', 'mandatory': 0, 'searchable': 
1}
{'read_only': 0, 'trait': 'HL7/Sex', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/PatientAlias', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/Race', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/PatientAddress', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/CountyCode', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/PhoneNumber_Home', 'mandatory': 0, 'searchable': 
1}
{'read_only': 0, 'trait': 'HL7/PhoneNumber_Business', 'mandatory': 0, 
'searchable': 1}
{'read_only': 0, 'trait': 'HL7/PrimaryLanguage', 'mandatory': 0, 'searchable': 
1}
{'read_only': 0, 'trait': 'HL7/MaritalStatus', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/Religion', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/PatientAccountNumber', 'mandatory': 0, 
'searchable': 1}
{'read_only': 0, 'trait': 'HL7/SSNNumber', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/DriversLicenseNumber', 'mandatory': 0, 
'searchable': 1}
{'read_only': 0, 'trait': 'HL7/MothersIdentifier', 'mandatory': 0, 
'searchable': 1}
{'read_only': 0, 'trait': 'HL7/EthnicGroup', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/BirthPlace', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/MultipleBirthIndicator', 'mandatory': 0, 
'searchable': 1}
{'read_only': 0, 'trait': 'HL7/BirthOrder', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/Citizenship', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/VeteransMilitaryStatus', 'mandatory': 0, 
'searchable': 1}
{'read_only': 0, 'trait': 'HL7/Nationality', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'HL7/PatientDeathDateandTime', 'mandatory': 0, 
'searchable': 1}
{'read_only': 0, 'trait': 'HL7/PatientDeathIndicator', 'mandatory': 0, 
'searchable': 1}
{'read_only': 0, 'trait': 'vCard/FN', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'vCard/N', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'vCard/PHOTO', 'mandatory': 0, 'searchable': 0}
{'read_only': 0, 'trait': 'vCard/BDAY', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'vCard/ADR', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'vCard/ADR;HOME', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'vCard/TEL', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'vCard/TEL;CELL', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'vCard/EMAIL', 'mandatory': 0, 'searchable': 1}
{'read_only': 0, 'trait': 'vCard/SOUND', 'mandatory': 0, 'searchable': 0}
{'read_only': 0, 'trait': 'vCard/URL', 'mandatory': 0, 'searchable': 1}
>>> specTraits = PersonIdService.SpecifiedTraits("","")
>>> print specTraits.__dict__
{'_v': '', '_d': ''}
>>> specTraits.traits = ['HL7/PatientName', 'HL7/Sex', 'HL7/DateTimeOfBirth', 
>>> 'HL7/PatientAddress' ]
>>> print specTraits
_d = SOME_TRAITS, traits = ['HL7/PatientName', 'HL7/Sex', 
'HL7/DateTimeOfBirth', 'HL7/PatientAddress']
>>> profile_access = idComponent._get_profile_access()
>>> traits = profile_access.get_profile('18', specTraits)
>>> for x in traits:
...   print x.__dict__
...
{'name': 'HL7/PatientName', 'value': <omniORB.CORBA.Any instance at 0x826690c>}
{'name': 'HL7/Sex', 'value': <omniORB.CORBA.Any instance at 0x826229c>}
{'name': 'HL7/PatientAddress', 'value': <omniORB.CORBA.Any instance at 
0x826210c>}
>>> for x in traits:
...   print x.value.__dict__
...
{'_v': 'Nicklin^Peter^^^^', '_t': <omniORB.tcInternal.TypeCode_string instance 
at 0x8266bfc>}
{'_v': 'M', '_t': <omniORB.tcInternal.TypeCode_string instance at 0x8266814>}
{'_v': '458 Channel View Lane^^London^^666777^UK^', '_t': 
<omniORB.tcInternal.TypeCode_string instance at 0x826239c>}
>>>
>>> specTraits.traits = ['HL7/PatientName', 'HL7/Sex', 'HL7/DateTimeofBirth', 
>>> 'HL7/PatientAddress' ]
>>> traits = profile_access.get_profile('18', specTraits)
>>> for x in traits:
...   print x.value.__dict__
...
{'_v': 'Nicklin^Peter^^^^', '_t': <omniORB.tcInternal.TypeCode_string instance 
at 0x825ec6c>}
{'_v': 'M', '_t': <omniORB.tcInternal.TypeCode_string instance at 0x826190c>}
{'_v': '199802121200', '_t': <omniORB.tcInternal.TypeCode_string instance at 
0x825efac>}
{'_v': '458 Channel View Lane^^London^^666777^UK^', '_t': 
<omniORB.tcInternal.TypeCode_string instance at 0x825f22c>}
>>>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]