You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jonathan Kupferman (JIRA)" <ji...@apache.org> on 2009/05/21 23:21:45 UTC
[jira] Created: (THRIFT-515) Having the same namespace in separate
thrift files generates
Having the same namespace in separate thrift files generates
-------------------------------------------------------------
Key: THRIFT-515
URL: https://issues.apache.org/jira/browse/THRIFT-515
Project: Thrift
Issue Type: Bug
Components: Compiler (Python)
Reporter: Jonathan Kupferman
Priority: Minor
If there are two thrift files which use the same namespace the generated python code does not work. A sample case is the two thrift files provided below:
--------test.thrift----------
namespace py Sample
struct Name {
1: string n
}
struct User {
1: i32 id,
2: Name user_name
}
-------- end test.thrift----------
--------test_service.thrift-----------
include "test.thrift"
namespace py Sample
service TestService {
test.User get_user(1: i64 id),
test.Name get_user_name(1: i64 id),
}
--------end test_service.thrift-----------
This happens because the ttypes for test.thrift are clobbered by the ttypes for TestService. As a result TestService is not imported correctly.
>>> import Sample
>>> import Sample.ttypes
>>> from Sample import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "Sample/TestService.py", line 205, in <module>
class get_user_result:
File "Sample/TestService.py", line 212, in get_user_result
(0, TType.STRUCT, 'success', (Sample.ttypes.User, Sample.ttypes.User.thrift_spec), None, ), # 0
AttributeError: 'module' object has no attribute 'User'
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (THRIFT-515) Having the same namespace in
separate thrift files generates non-working code
Posted by "Rob Slifka (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751076#action_12751076 ]
Rob Slifka commented on THRIFT-515:
-----------------------------------
We just ran into this today.
Why is this filed as minor?
Is it uncommon for people to have more than one service?
> Having the same namespace in separate thrift files generates non-working code
> -----------------------------------------------------------------------------
>
> Key: THRIFT-515
> URL: https://issues.apache.org/jira/browse/THRIFT-515
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Python)
> Reporter: Jonathan Kupferman
> Priority: Minor
>
> If there are two thrift files which use the same namespace the generated python code does not work. A sample case is the two thrift files provided below:
> --------test.thrift----------
> namespace py Sample
> struct Name {
> 1: string n
> }
> struct User {
> 1: i32 id,
> 2: Name user_name
> }
> -------- end test.thrift----------
> --------test_service.thrift-----------
> include "test.thrift"
> namespace py Sample
> service TestService {
> test.User get_user(1: i64 id),
> test.Name get_user_name(1: i64 id),
> }
> --------end test_service.thrift-----------
> This happens because the ttypes for test.thrift are clobbered by the ttypes for TestService. As a result TestService is not imported correctly.
> >>> import Sample
> >>> import Sample.ttypes
> >>> from Sample import *
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "Sample/TestService.py", line 205, in <module>
> class get_user_result:
> File "Sample/TestService.py", line 212, in get_user_result
> (0, TType.STRUCT, 'success', (Sample.ttypes.User, Sample.ttypes.User.thrift_spec), None, ), # 0
> AttributeError: 'module' object has no attribute 'User'
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (THRIFT-515) Having the same namespace in separate
thrift files generates non-working code
Posted by "Jonathan Kupferman (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-515?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jonathan Kupferman updated THRIFT-515:
--------------------------------------
Summary: Having the same namespace in separate thrift files generates non-working code (was: Having the same namespace in separate thrift files generates )
> Having the same namespace in separate thrift files generates non-working code
> -----------------------------------------------------------------------------
>
> Key: THRIFT-515
> URL: https://issues.apache.org/jira/browse/THRIFT-515
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Python)
> Reporter: Jonathan Kupferman
> Priority: Minor
>
> If there are two thrift files which use the same namespace the generated python code does not work. A sample case is the two thrift files provided below:
> --------test.thrift----------
> namespace py Sample
> struct Name {
> 1: string n
> }
> struct User {
> 1: i32 id,
> 2: Name user_name
> }
> -------- end test.thrift----------
> --------test_service.thrift-----------
> include "test.thrift"
> namespace py Sample
> service TestService {
> test.User get_user(1: i64 id),
> test.Name get_user_name(1: i64 id),
> }
> --------end test_service.thrift-----------
> This happens because the ttypes for test.thrift are clobbered by the ttypes for TestService. As a result TestService is not imported correctly.
> >>> import Sample
> >>> import Sample.ttypes
> >>> from Sample import *
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "Sample/TestService.py", line 205, in <module>
> class get_user_result:
> File "Sample/TestService.py", line 212, in get_user_result
> (0, TType.STRUCT, 'success', (Sample.ttypes.User, Sample.ttypes.User.thrift_spec), None, ), # 0
> AttributeError: 'module' object has no attribute 'User'
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (THRIFT-515) Having the same namespace in
separate thrift files generates non-working code
Posted by "Rob Slifka (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751126#action_12751126 ]
Rob Slifka commented on THRIFT-515:
-----------------------------------
Thanks David, that's a good workaround that hadn't occurred to me.
I just assumed it was possible to define only one service per Thrift file =)
I updated the tutorial wiki to add a small example.
> Having the same namespace in separate thrift files generates non-working code
> -----------------------------------------------------------------------------
>
> Key: THRIFT-515
> URL: https://issues.apache.org/jira/browse/THRIFT-515
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Python)
> Reporter: Jonathan Kupferman
> Priority: Minor
>
> If there are two thrift files which use the same namespace the generated python code does not work. A sample case is the two thrift files provided below:
> --------test.thrift----------
> namespace py Sample
> struct Name {
> 1: string n
> }
> struct User {
> 1: i32 id,
> 2: Name user_name
> }
> -------- end test.thrift----------
> --------test_service.thrift-----------
> include "test.thrift"
> namespace py Sample
> service TestService {
> test.User get_user(1: i64 id),
> test.Name get_user_name(1: i64 id),
> }
> --------end test_service.thrift-----------
> This happens because the ttypes for test.thrift are clobbered by the ttypes for TestService. As a result TestService is not imported correctly.
> >>> import Sample
> >>> import Sample.ttypes
> >>> from Sample import *
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "Sample/TestService.py", line 205, in <module>
> class get_user_result:
> File "Sample/TestService.py", line 212, in get_user_result
> (0, TType.STRUCT, 'success', (Sample.ttypes.User, Sample.ttypes.User.thrift_spec), None, ), # 0
> AttributeError: 'module' object has no attribute 'User'
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (THRIFT-515) Having the same namespace in
separate thrift files generates non-working code
Posted by "David Reiss (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/THRIFT-515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12751090#action_12751090 ]
David Reiss commented on THRIFT-515:
------------------------------------
Define them in the same file, or use submodules.
> Having the same namespace in separate thrift files generates non-working code
> -----------------------------------------------------------------------------
>
> Key: THRIFT-515
> URL: https://issues.apache.org/jira/browse/THRIFT-515
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (Python)
> Reporter: Jonathan Kupferman
> Priority: Minor
>
> If there are two thrift files which use the same namespace the generated python code does not work. A sample case is the two thrift files provided below:
> --------test.thrift----------
> namespace py Sample
> struct Name {
> 1: string n
> }
> struct User {
> 1: i32 id,
> 2: Name user_name
> }
> -------- end test.thrift----------
> --------test_service.thrift-----------
> include "test.thrift"
> namespace py Sample
> service TestService {
> test.User get_user(1: i64 id),
> test.Name get_user_name(1: i64 id),
> }
> --------end test_service.thrift-----------
> This happens because the ttypes for test.thrift are clobbered by the ttypes for TestService. As a result TestService is not imported correctly.
> >>> import Sample
> >>> import Sample.ttypes
> >>> from Sample import *
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "Sample/TestService.py", line 205, in <module>
> class get_user_result:
> File "Sample/TestService.py", line 212, in get_user_result
> (0, TType.STRUCT, 'success', (Sample.ttypes.User, Sample.ttypes.User.thrift_spec), None, ), # 0
> AttributeError: 'module' object has no attribute 'User'
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.