Git Product home page Git Product logo

Comments (5)

mmerickel avatar mmerickel commented on June 10, 2024

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.

mmerickel avatar mmerickel commented on June 10, 2024

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.

tflorac avatar tflorac commented on June 10, 2024

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.

mmerickel avatar mmerickel commented on June 10, 2024

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.

tflorac avatar tflorac commented on June 10, 2024

from pyramid_rpc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.