You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by meng <me...@f-road.com.cn> on 2016/06/10 08:52:01 UTC

a problem about thrift nested struct in python

Hello everyone,

     I'm a new user of thrift.  There is a "nested struct in thrift
file"issue block me. Maybe somebody could give me some advicesJ

 

Firstly, this is my thrift file 

  struct DeliverInfoVo {

                   .

                   }

struct GetOrderDetailByBankManageVoRes { .

                       19:DeliverInfoVo deliverInfoVo,

                          }

 

Then I compiled it as a python by "thrift -r -gen " and it generated
"constants.py, ttypes.py".

 

Finally, a issue appeared when I run client code:

(18, TType.STRUCT, 'deliverInfoVo', (DeliverInfoVo,
DeliverInfoVo.thrift_spec), None, ), # 18

NameError: name 'DeliverInfoVo' is not defined

 

     I found 'DeliverInfoVo' is a class in ttypes.py, not a module. As I
know, there is OK if generate java package. 

 

     I would appreciate it very much if anyone help me.

 

 

Thanks,

Meng