Comments (5)
Doing the parsing in a factory is also a great way to provide support for a full-traversal application.
Consider the public api pyramid_rpc.jsonrpc.JSONRPCRootFactory
which would be the replacement for the predicate.
def myFactory(request):
if request.rpc_method == 'addUser':
return AddUser(request)
config.set_root_factory(JSONRPCRootFactory(myFactory))
@jsonrpc_method(context=AddUser, permission='create_users')
def addUser(request):
# add a user
Note that myFactory
could be a full-traversal app that did something. We just made the jsonrpc_method
work without an endpoint but is still dependent on a (context, name, rpc_method)
for view lookup.
from pyramid_rpc.
Removing the endpoint concept is a little hairy because parts of it are used to pass settings to jsonrpc_method
but this could probably be solved by config.set_default_jsonrpc_endpoint_options()
or something. I haven't thought through those details yet but this gets us to the point where we can parse the request at least.
from pyramid_rpc.
From a "user" point of view, what I would like is to be able to declare a JSON-RPC or XML-RPC view like a common Pyramid view, using traversal... For example :
@jsonrpc_method(context=IMyContext, permission='create_users')
def my_jsonrpc_method(request):
"""Request should receive a context attribute..."""
Calling URL required to access this method should use common objects traversal : /object1/object2/my_context, and method name is the name of the function...
from pyramid_rpc.
I understand but in order to dispatch on the method it's necessary to parse the body. Using the JSONRPCRootFactory
(or currently the route predicate) allows this to happen. Alternatively I could have it be completely lazy and only parse it during view lookup but that feels a little weird to me.
from pyramid_rpc.
from pyramid_rpc.
Related Issues (20)
- JSON-RPC may be broken on Pyramid 1.1 HOT 1
- Tests don't pass under 2.4 HOT 1
- JSON-RPC methods should be able to be invoked using HTTP GET HOT 4
- DeprecationWarning get always displayed when using python2.6 HOT 3
- AMF support broken? HOT 5
- Issue with named parameters in the request.params HOT 9
- Need to distinguish Forbidden from RequestInvalid in jsonrpc HOT 2
- JsonRpcError: data argument never used HOT 1
- Allow custom JSONEncoder subclasses for JSON-RPC endpoints HOT 3
- config.scan not found @xmlrpc_method HOT 15
- decide how to handle json-rpc responses
- Encoding error HOT 1
- Support json rpc 2.0 batch HOT 3
- Allow us to disable exception views HOT 2
- JSON-RPC traversal HOT 6
- MethodPredicate throws AttributeError when tested against batched requests HOT 1
- Cannot handle *args, **kwargs decorators
- MessagePack support HOT 2
- install error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyramid_rpc.