[omniORB] BAD_PARAMS_WrongPythonType in deeply nested structure

baileyk@schneider.com baileyk@schneider.com
Fri Dec 20 15:18:01 2002


sorry if this is a duplicate post...


If you find an easy way, let me know.

What I've done in the same situation is dump the structure out as text and
read through it looking for the problem.  You could use an XML
serialization method to do that, or there's some code I use listed below.
It's worked for all IDL types I've ever used it on.  I just read the output
looking for wrong datatypes.

Kendall

# note: my IDL time type is minutes since 1/1/1901 gmt.
# you may want to just remove the check for var names with "time"
# in them...
#------------------------------------------------------------------------
import sys, time, types, cPickle, cStringIO, os
from os import path

epochOffset = 2177452800L
#------------------------------------------------------------------------
basic_types = [
   types.StringType,
   types.IntType,
   types.LongType,
   types.FloatType,
   types.ComplexType,
   types.UnicodeType ]
#------------------------------------------------------------------------
def tm2str( t ) :
   global epochOffset
   t = long(t) * 60L - epochOffset
   return time.ctime( t )
#------------------------------------------------------------------------
def prt(val, out = sys.stdout, d = "", seen = None):
   global basic_types
   if not seen : seen = { id(val) : val }
   else :
      if (type(val) not in basic_types) and seen.has_key( id(val) ) :
         out.write("%sseen id = %d\n" % (d, id(val)) )
         return
   seen[id(val)] = val
   if type(val) == types.InstanceType :
      out.write("%sInstance id(%d) of type %s:\n" %
                 (d, id(val), val.__class__.__name__))
      for i in val.__dict__.keys() :
         f = val.__dict__[i]
         if i.find("time") >= 0 :
            out.write("%s   field %s : " % (d, i))
            out.write("%s\n" % tm2str(f) )
         else:
            out.write("%s   field %s\n" % (d, i))
            prt( f , out, d + "      ", seen)
   elif type(val) == types.TupleType :
      out.write("%sTuple of len %d\n" % ( d, len(val) ))
      for i in val :
         prt( i, out, d + "   ", seen )
   elif type(val) == types.ListType :
      out.write("%sList of len %d\n" % ( d, len(val) ))
      for i in val :
         prt( i, out, d + "   ", seen )
   elif type(val) == types.DictionaryType :
      out.write("%sDict of len %d\n" % ( d, len(val.keys()) ))
      for i in val.keys() :
         out.write("%sKey:\n" % d)
         prt( i, out, d + "   ", seen )
         out.write("%sValue:\n" % d)
         prt( val[i], out, d + "   ", seen )
   else :
      out.write("%s%s\n" % (d, str(val)))





                                                                                                                          
                    "I-Currey, Jason"                                                                                     
                    <Jason.Currey@Australia.Boei       To:     "'omniorb-list@omniorb-support.com'"                       
                    ng.com>                             <omniorb-list@omniorb-support.com>                                
                    Sent by:                           cc:                                                                
                    omniorb-list-admin@omniorb-s       Fax to:                                                            
                    upport.com                         Subject:     [omniORB] BAD_PARAMS_WrongPythonType in deeply nested 
                                                        structure                                                         
                                                                                                                          
                    12/19/2002 03:26 PM                                                                                   
                                                                                                                          
                                                                                                                          




Hi,

I am using OmniOrbPy and am getting a BAD_PARAMS_WrongPythonType exception
when calling an IDL method which takes a heavily nested structure type.
Does
anyone know a way of finding the particular item in the structure causing
the problem? Or is there a way to handle these sorts of problems
generically, like a fill in the blanks method?

Thanks,

Jason