thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Kupferman <jkupfer...@umail.ucsb.edu>
Subject Issue with Thrift Python Bindings
Date Thu, 21 May 2009 04:39:52 GMT
Hi all,
I am trying to use the generated Python for a simple thrift file and seem to
be running into issues. I am able to generate and use the Ruby code without
a problem yet I seem to be doing something wrong with the python code.
Included below are the two thrift files used:

--------test.thrift----------
namespace py Sample

struct Name {
    1: string n
}

struct User {
    1: i64 id,
    2: Name user_name
}
-------- end test.thrift----------

--------test_service.thrift-----------

include "test.thrift"

namespace py Sample

service TestService {
  test.User get_user(1: i64 id),
  test.Name get_user_name(1: i64 id),
}
--------end test_service.thrift-----------

I generate the python code using "thrift --gen py test.thrift" and then
"thrift --gen py test_service.thrift" (I've also tried recursive with the
same result). I then go in the gen-py directory and type:

>>> import Sample
>>> import Sample.ttypes
>>> from Sample import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Sample/TestService.py", line 205, in <module>
    class get_user_result:
  File "Sample/TestService.py", line 212, in get_user_result
    (0, TType.STRUCT, 'success', (Sample.ttypes.User,
Sample.ttypes.User.thrift_spec), None, ), # 0
AttributeError: 'module' object has no attribute 'User'

Am I doing something wrong here?

Thanks

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message