THRIFT-1494 Python generated "Service-remote" script doesn't honor service inheritance

Patch: Nathaniel Cook


git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1410130 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Roger Meier 2012-11-16 00:51:59 +00:00
parent 8252577ec9
commit 3e5e9d0901

View File

@ -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 <<