txprotobuf

55 views
Skip to first unread message

Johan Euphrosine

unread,
Jul 18, 2008, 6:31:18 AM7/18/08
to Protocol Buffers, Twisted general discussion
Hi,

I'm working on a twisted implementation of protocol buffers RPC here:
http://launchpad.net/txprotobuf/
http://bazaar.launchpad.net/~proppy/txprotobuf/master/changes

Feel free to join :)

Twisted:
Twisted is an event-driven networking engine written in
Python and licensed under the MIT license.
http://twistedmatrix.com/trac/

Protocol Buffers:
Protocol Buffers - Google's data interchange format
http://code.google.com/p/protobuf/
--
bou ^

Kenton Varda

unread,
Jul 18, 2008, 12:52:51 PM7/18/08
to Johan Euphrosine, Protocol Buffers, Twisted general discussion
Added to wiki:

http://code.google.com/p/protobuf/wiki/OtherLanguages

(It's not a language but I don't have a page for RPC implementations yet...  will have to work on that...)

[CPR]-AL.exe

unread,
Jul 22, 2008, 6:12:29 AM7/22/08
to Protocol Buffers
Sorry for my stupidity, I was browsing the source code for some
time... but i cannot figure out, how can I use it. What should I do to
call a remote procedure on some server?

On 18 июл, 14:31, "Johan Euphrosine" <pro...@aminche.com> wrote:
> Hi,
>
> I'm working on a twisted implementation of protocol buffers RPC here:http://launchpad.net/txprotobuf/http://bazaar.launchpad.net/~proppy/txprotobuf/master/changes
>
> Feel free to join :)
>
> Twisted:
> Twisted is an event-driven networking engine written in
> Python and licensed under the MIT license.http://twistedmatrix.com/trac/

Johan Euphrosine

unread,
Jul 22, 2008, 6:37:57 AM7/22/08
to [CPR]-AL.exe, Protocol Buffers
Hi,

if you take a look at the test code:
http://bazaar.launchpad.net/~proppy/txprotobuf/master/annotate/23?file_id=test_service.py-20080718124028-na73b03l2wxiv0v8-1

It shows how to make a call using txprotobuf.Proxy class with a
twisted procotol object:
102 22 def testProxy(self):
103 d = self.connectClient()
104 def clientConnected(protocol):
105 23 proxy = txprotobuf.Proxy(TestService_Stub(protocol))
106 22 request = TestRequest()
107 request.text = "proxycall"
108 d = proxy.TestMethod(request)
109 d.addCallback(lambda response:
self.assertEquals(response.text, request.text))
110 return d
111 d.addCallback(clientConnected)
112 return d

2008/7/22 [CPR]-AL.exe <CPR.A...@gmail.com>:

--
bou ^

[CPR]-AL.exe

unread,
Jul 22, 2008, 7:34:32 AM7/22/08
to Protocol Buffers
Mmm... I wonder, what is TestService_Stub... it isn't defined in the
proto file, but is somehow imported from it...

On 22 июл, 14:37, "Johan Euphrosine" <pro...@aminche.com> wrote:
> Hi,
>
> if you take a look at the test code:http://bazaar.launchpad.net/~proppy/txprotobuf/master/annotate/23?fil...
>
> It shows how to make a call using txprotobuf.Proxy class with a
> twisted procotol object:
> 102     22          def testProxy(self):
> 103                     d = self.connectClient()
> 104                     def clientConnected(protocol):
> 105     23                  proxy = txprotobuf.Proxy(TestService_Stub(protocol))
> 106     22                  request = TestRequest()
> 107                         request.text = "proxycall"
> 108                         d = proxy.TestMethod(request)
> 109                         d.addCallback(lambda response:
> self.assertEquals(response.text, request.text))
> 110                         return d
> 111                     d.addCallback(clientConnected)
> 112                     return d
>
> 2008/7/22 [CPR]-AL.exe <CPR.AL....@gmail.com>:
>
>
>
>
>
> > Sorry for my stupidity, I was browsing the source code for some
> > time... but i cannot figure out, how can I use it. What should I do to
> > call a remote procedure on some server?
>
> > On 18 июл, 14:31, "Johan Euphrosine" <pro...@aminche.com> wrote:
> >> Hi,
>
> >> I'm working on a twisted implementation of protocol buffers RPC here:http://launchpad.net/txprotobuf/http://bazaar.launchpad.net/~proppy/t...

Kenton Varda

unread,
Jul 22, 2008, 1:32:04 PM7/22/08
to [CPR]-AL.exe, Protocol Buffers
2008/7/22 [CPR]-AL.exe <CPR.A...@gmail.com>:

Mmm... I wonder, what is TestService_Stub... it isn't defined in the
proto file, but is somehow imported from it...

For a service called "Foo", the protocol compiler automatically generates a class called "Foo_Stub".  See the docs:


Johan Euphrosine

unread,
Jul 22, 2008, 1:33:28 PM7/22/08
to [CPR]-AL.exe, Protocol Buffers
TestService_Stub is in test_pb2.py which is generated from
test/test.proto using the protobuf target in the Makefile:
protoc -I. --python_out=. test/test.proto


2008/7/22 [CPR]-AL.exe <CPR.A...@gmail.com>:

--
bou ^

[CPR]-AL.exe

unread,
Jul 22, 2008, 3:48:08 PM7/22/08
to Protocol Buffers
What's the purpose of generating a "_Stub" class? Why not to use the
original?..

On Jul 22, 9:32 pm, "Kenton Varda" <ken...@google.com> wrote:
> 2008/7/22 [CPR]-AL.exe <CPR.AL....@gmail.com>:
>
> > Mmm... I wonder, what is TestService_Stub... it isn't defined in the
> > proto file, but is somehow imported from it...
>
> For a service called "Foo", the protocol compiler automatically generates a
> class called "Foo_Stub". See the docs:
>
> http://code.google.com/apis/protocolbuffers/docs/reference/python-gen...

Kenton Varda

unread,
Jul 22, 2008, 7:22:44 PM7/22/08
to [CPR]-AL.exe, Protocol Buffers
The original is an abstract interface, mean to be subclassed.  A stub is not meant to be subclassed, because it implements all its methods by making RPCs.
Reply all
Reply to author
Forward
0 new messages