If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!


  • 0
    mrgrieves  14 years ago
    I tried setting systemListMethods.__name__ and it didn't work. The login_url value is set for the entire application so there's no way to have different values for JSON-RPC calls and regular view calls. I did think of an alternative approach however. The login_url could left alone so as to not break authentication for regular views. A new controller called BasicJSONRPCLogin.py could be created with the following: from gluon.tools import Service service = Service(globals()) def call(): return service() @service.jsonrpc def systemListMethods(): #Could probably be rendered dynamically return ["UserIsLoggedIn"] @service.jsonrpc def UserIsLoggedIn(): return auth.is_logged_in() A second DataController object, let's call it LoginController, could be created with reference to this call controller. LoginController does *not* require authentication. We can then make a call to LoginController.UserIsLoggedIn before every call to DataController. If the user isn't log, we popup the login screen. I quickly tried having both controllers at the same time (one with authentication and one without) and it seems to work well. It's not a great solution since we're doubling the number of required requests but it's an option.

Commented on:

Enables your javascript to call web2py controller actions directly using JSON-RPC as a transport

Hosting graciously provided by:
Python Anywhere