You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jens Geyer (JIRA)" <ji...@apache.org> on 2015/06/16 15:52:02 UTC

[jira] [Closed] (THRIFT-3188) Python classes not created from thrift build

     [ https://issues.apache.org/jira/browse/THRIFT-3188?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jens Geyer closed THRIFT-3188.
------------------------------
    Resolution: Won't Fix
      Assignee: Jens Geyer

That's true, and it is by design. 

First, Thrift always overwrites any existing gen-* files without warning, because typically no one should edit them manually anyways. So the assumption is that anything generated can be safely overwritten. 

Next, Thrift files always should have their own namespace, one per file. In particular it is a bad idea, to split one namespace across multiple Thrift IDL files. Even with the {{-r}} argument specified, the Thrift compiler always treats each file independently of each other. 

> Python classes not created from thrift build
> --------------------------------------------
>
>                 Key: THRIFT-3188
>                 URL: https://issues.apache.org/jira/browse/THRIFT-3188
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Library
>    Affects Versions: 0.9.2
>         Environment: Python, Linux
>            Reporter: Jeffery Aronhalt
>            Assignee: Jens Geyer
>              Labels: class-generation, namespace, python
>
> If multiple .thrift files in the same directory share a python namespace and struct definitions exist in more than one of those files, then ONLY the structs in the first targeted .thrift file get generated. Services defined in each file are generated, though, which results in a NameError when importing that service. 
> Ex:
> {code:title=~/proj/d/a.thrift}
> namespace java com.p.api
> namespace py p_different.api.net
> namespace cpp p.api
> include "../model/Common.thrift"
> struct ARequest
> {
> 1: required i64 ID;
> }
> struct AResponse
> {
> 1: required i64 ID;
> }
> service AService
> {
>  AResponse
>  save(1: Common.Context ctx, 2: ARequest req)
>  throws (1: Common.Exception e);
> }
> {code}
> {code:title=~/proj/d/b.thrift}
> namespace java com.p.api
> namespace py p_different.api.net 
> namespace cpp p.api
> include "../model/Common.thrift"
> struct BRequest
> {
> 1: required i64 ID;
> }
> struct BResponse
> {
> 1: required i64 ID;
> }
> service BService
> {
>  BResponse
>  save(1: Common.Context ctx, 2: BRequest req)
>  throws (1: Common.Exception e);
> }
> {code}
> The A* service and structs are successfully generated in python and all works well. However, while BService gets generated successfully, when one tries to import BService, a NameError is thrown for BRequest not having a definition. 
> I've grep'd the genereated sources and sure enough, there's no class declaration for BRequest nor BResponse.
> If I append the py namespace with a subnamespace, then all works well, but I wonder if this is the intended behavior which I doubt because the compiler doesn't barf.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)