Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make JSON-RPC method registration/discovery either more explicit, or completely implicit. #49

Open
ksze opened this issue Sep 2, 2013 · 1 comment

Comments

@ksze
Copy link

ksze commented Sep 2, 2013

Currently, we need to do this in urls.py:

from jsonrpc import jsonrpc_site
import myproj.myapp.views
urlpatterns = (
    # some url patterns ...
    url(r'^json/', jsonrpc_site.dispatch, name="jsonrpc_mountpoint"),
    # more url patterns ...
)

It is not immediately evident that the import myproj.myapp.views is actually useful. Somebody who inherits a project and needs to maintain it could erroneously believe that the import is not needed and decide to "clean it up".

I believe there are two possible ways to go:

Make it more explicit

This means having a jsonrpc_site.register function that takes these arguments:

  • entry point; e.g. r'^json/'
  • list of fully-qualified json rpc methods to register
  • the other usual parameters (e.g. url pattern name)

And the method will return a set of url pattern objects that can be appended to urlpatterns.

Make it completely implicit and work by convention

This means making the discovery of json rpc methods work somewhat like django.contrib.admin, where we don't need to import the views in urls.py. Instead, have django-json-rpc scan through all the apps listed in INSTALLED_APPS of Django settings.

@samuraisam
Copy link
Owner

I welcome pull requests!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants