Skip to content
Browse files

THRIFT-1494 Python generated "Service-remote" script doesn't honor se…

…rvice inheritance

Patch: Nathaniel Cook


git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1410130 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 8252577 commit 3e5e9d09016dfbbda7a7a46828faf9cab4235fb8 @bufferoverflow bufferoverflow committed Nov 16, 2012
Showing with 11 additions and 2 deletions.
  1. +11 −2 compiler/cpp/src/generate/t_py_generator.cc
View
13 compiler/cpp/src/generate/t_py_generator.cc
@@ -284,6 +284,7 @@ class t_py_generator : public t_generator {
std::ofstream f_service_;
std::string package_dir_;
+ std::string module_;
};
@@ -298,6 +299,7 @@ void t_py_generator::init_generator() {
// Make output directory
string module = get_real_py_module(program_, gen_twisted_);
package_dir_ = get_out_dir();
+ module_ = module;
while (true) {
// TODO: Do better error checking here.
MKDIR(package_dir_.c_str());
@@ -1404,6 +1406,13 @@ void t_py_generator::generate_service_client(t_service* tservice) {
*/
void t_py_generator::generate_service_remote(t_service* tservice) {
vector<t_function*> functions = tservice->get_functions();
+ //Get all function from parents
+ t_service* parent = tservice->get_extends();
+ while(parent != NULL) {
+ vector<t_function*> p_functions = parent->get_functions();
+ functions.insert(functions.end(), p_functions.begin(), p_functions.end());
+ parent = parent->get_extends();
+ }
vector<t_function*>::iterator f_iter;
string f_remote_name = package_dir_+"/"+service_name_+"-remote";
@@ -1423,8 +1432,8 @@ void t_py_generator::generate_service_remote(t_service* tservice) {
endl;
f_remote <<
- "import " << service_name_ << endl <<
- "from ttypes import *" << endl <<
+ "from " << module_ << " import " << service_name_ << endl <<
+ "from " << module_ << ".ttypes import *" << endl <<
endl;
f_remote <<

0 comments on commit 3e5e9d0

Please sign in to comment.
Something went wrong with that request. Please try again.