<HTML>
<HEAD>
<TITLE>RPC design questions</TITLE>
</HEAD>
<BODY>
<FONT FACE="Calibri, Verdana, Helvetica, Arial"><SPAN STYLE='font-size:11pt'>I'm currently making some light-weight RPC/PubSub over WebSockets<BR>
using Twisted.<BR>
<BR>
I have two design-like questions where I'd be happy for advice/options ...<BR>
<BR>
The first is definitely Twisted related, the second not strictly, ..<BR>
<BR>
Tobias<BR>
<BR>
<BR>
1)<BR>
I'd like to chain RPC calls, i.e.<BR>
<BR>
self.call(23, &quot;square&quot;).addCallback(self.call, &quot;sqrt&quot;).addCallback(self.show)<BR>
<BR>
<a href="https://github.com/oberstet/Autobahn/blob/dev-rpc/demo/rpc/simple/simple_client.py">https://github.com/oberstet/Autobahn/blob/dev-rpc/demo/rpc/simple/simple_client.py</a><BR>
<BR>
self.call(&lt;arg&gt;, &lt;procedure&gt;) will return a deferred, &lt;arg&gt; is the marshalled argument<BR>
for the RPC, and &lt;procedure&gt; is the remote procedure identifier.<BR>
<BR>
Now, the nice thing is, I can chain the result from one call to the next like in the<BR>
example above.<BR>
<BR>
What I find less nice is that I have to have that order : &lt;arg&gt;, &lt;procedure&gt;<BR>
since the result of the first deferred will be passed as the first argument to<BR>
the second, and only then will the additional arguments be passed (in above<BR>
example the &quot;sqrt&quot;)<BR>
<BR>
How can I retain the - which I find - natural order for arguments?<BR>
<BR>
self.call(&lt;procedure&gt;, &lt;arg&gt;) <BR>
self.call(&quot;square&quot;, 6).addCallback(self.call, &quot;sqrt&quot;).addCallback(self.show)<BR>
<BR>
=&gt; not working, the 2nd self.call receives 36, &quot;sqrt&quot; ..<BR>
<BR>
<BR>
2)<BR>
The server side methods a hooked up using decorators, like<BR>
<BR>
class SimpleServerProtocol(AutobahnServerProtocol):<BR>
<BR>
   @AutobahnRpc<BR>
   def square(self, arg):<BR>
      return arg * arg<BR>
<BR>
<BR>
<a href="https://github.com/oberstet/Autobahn/blob/dev-rpc/demo/rpc/simple/simple_server.py">https://github.com/oberstet/Autobahn/blob/dev-rpc/demo/rpc/simple/simple_server.py</a><BR>
<BR>
Here, AutobahnServerProtocol derives (indirectly) from Twisted Protocol.<BR>
<BR>
The decorator will register the method for RPC under &quot;square&quot;.<BR>
<BR>
<a href="https://github.com/oberstet/Autobahn/blob/dev-rpc/lib/python/autobahn/autobahn.py">https://github.com/oberstet/Autobahn/blob/dev-rpc/lib/python/autobahn/autobahn.py</a><BR>
<BR>
That is all nice and simple, however I am wondering if it's a good idea to<BR>
do that auto-registering on a Protocol derived class.<BR>
<BR>
I mean, the alternative could be having the user call something like<BR>
<BR>
registerRpcObject(&lt;any class instance with RPC decorators&gt;, &lt;base URI&gt;)<BR>
<BR>
in Protocol.connectionMade(), which then would auto-register all decorated<BR>
methods in &lt;any class instance ..&gt;<BR>
<BR>
What do you think would be better?<BR>
<BR>
<BR>
<BR>
&nbsp;<BR>
<BR>
<BR>
</SPAN></FONT>
</BODY>
</HTML>