Pylons / pyramid_rpc

RPC plugins for pyramid. XML-RPC, JSON-RPC, etc.
https://docs.pylonsproject.org/projects/pyramid-rpc/en/latest/
Other
27 stars 20 forks source link

JSON-RPC traversal #31

Open tflorac opened 9 years ago

tflorac commented 9 years ago

Hi, I'm trying to use pyramid_rpc package. How can I use it, so that I can call a "JSON-RPC" method on a given object (providing an interface) accessed through ZODB traversal?

Thanks, for any help, Thierry

mmerickel commented 9 years ago

JSON-RPC is a protocol over a particular endpoint. It does not mix well with url traversal. I don't have a good answer for you without more details, so I'll leave it at that.

tflorac commented 9 years ago

Hi, I was using JSON-RPC and sometimes XML-RPC before within Zope3 projects, where remote procedures were applied on a given "context" accessed through URL traversal. So, as traversal is mentioned in your package documentation, I was wondering if the same scheme could be used with Pyramid RPC (which would probably require to NOT declare endpoints, as objects URLs can't be pre-defined...).

Regards, Thierry

mmerickel commented 9 years ago

Can you give me an example? You'd be POSTing a method call to an arbitrary URL?

Have you looked at @mcdonc's pyramid_xmlrpc package which allows xmlrpc on any traversal context?

tflorac commented 9 years ago

Hi,

Le 2015-05-15 18:04, Michael Merickel a écrit :

Can you give me an example? You'd be POSTing a method call to an arbitrary URL?

Yes, the goal is to be able to define RPC methods on given objects classes, for whose instances can be stored anywhere into a ZODB.

Have you looked at @mcdonc [1]'s pyramid_xmlrpc package which allows xmlrpc on any traversal context?

pyramid_xmlrpc seems to be a little outdated and unmaintained... I don't remember if this was the only reason but I currently use pyramid_rpc package which id an "official" Pyramid package which can be used for XML-RPC as well as JSON-RPC. This package also mentions that it allows traversal to any content, but I can't figure out how it works... :-/

Regards, Thierry

mmerickel commented 9 years ago

Well "traversal to any context" isn't quite right, not sure where you're seeing that. You can specify a custom factory= and traverse= arg to each rpc endpoint, allowing you to do traversal after that endpoint is matched.

I think what you're asking for is interesting but I'm not sure how I'd support it right now. We would have to perform the json-rpc protocol detection on a global level instead of per-endpoint-url I think.

mmerickel commented 9 years ago

@tflorac can you look at the pattern I'm proposing in #37?