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

Jens Geyer updated THRIFT-3188:
-------------------------------
    Summary: Generated code gets overwritten if namespace is shared across 
multiple IDL files  (was: Python classes not created from thrift build)

> Generated code gets overwritten if namespace is shared across multiple IDL 
> files
> --------------------------------------------------------------------------------
>
>                 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)

Reply via email to