You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2012/11/16 01:51:59 UTC

svn commit: r1410130 - /thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc

Author: roger
Date: Fri Nov 16 00:51:59 2012
New Revision: 1410130

URL: http://svn.apache.org/viewvc?rev=1410130&view=rev
Log:
THRIFT-1494 Python generated "Service-remote" script doesn't honor service inheritance
Patch: Nathaniel Cook

Modified:
    thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc

Modified: thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc?rev=1410130&r1=1410129&r2=1410130&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc (original)
+++ thrift/trunk/compiler/cpp/src/generate/t_py_generator.cc Fri Nov 16 00:51:59 2012
@@ -284,6 +284,7 @@ class t_py_generator : public t_generato
   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_cl
  */
 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_re
     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 <<