[omniORB] Passing dictionary.

Duncan Grisby duncan@grisby.org
Thu Jun 20 10:06:01 2002


On Thursday 20 June, Nathaniel Smith wrote:

> I think you misunderstood -- "dictionary" is Python-ese for "hash
> table".  It's a basic mapping type, and I've wondered what the best
> way to send one down the wire is myself.  I don't really have a good
> answer, though; one option would of course be to wrap it in a CORBA
> object with methods "get", "set", etc., but if you want to actually
> send the whole dictionary across the wire, then you'll have to do some
> "marshalling" by hand.
> 
> Perhaps to send a dictionary mapping strings to strings, one could use
>   struct StrStrPair { string key, value; }
>   typedef sequence<StrStrPair> StrStrDictionary;
> and then pack/unpack by hand on each end of the connection.

Yes, that's a sensible representation for a Python dictionary. Of
course, Python dictionaries can contain values with any types, and
keys with a wide range of types, not just strings. To cope with all
Python dictionaries in a single CORBA type, you'd have to use a
sequence of structs of Anys. That would be a real pain, though.

ILU had (has?) an interesting feature where if you have a sequence of
structs, and the struct's member names are "key" and "value", it would
map that to a Python dictionary, rather than the normal Python
language mapping. I have resisted doing that sort of thing in
omniORBpy since it's a bit too magic for my liking.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan@grisby.org     --
   -- http://www.grisby.org --