Skip to content
Snippets Groups Projects
Commit 469881eb authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Review directsvc.py documentation.

parent 1d61fa47
No related branches found
No related tags found
No related merge requests found
plugin_dbui.directsvc.DirectSvc.dbg
===================================
.. currentmodule:: plugin_dbui.directsvc
.. automethod:: DirectSvc.dbg
\ No newline at end of file
plugin_dbui.directsvc.DirectSvc.echo
====================================
.. currentmodule:: plugin_dbui.directsvc
.. automethod:: DirectSvc.echo
\ No newline at end of file
plugin_dbui.directsvc.DirectSvc.error
=====================================
.. currentmodule:: plugin_dbui.directsvc
.. automethod:: DirectSvc.error
\ No newline at end of file
plugin_dbui.directsvc.DirectSvc.register
========================================
.. currentmodule:: plugin_dbui.directsvc
.. automethod:: DirectSvc.register
\ No newline at end of file
plugin_dbui.directsvc.DirectSvc.route
=====================================
.. currentmodule:: plugin_dbui.directsvc
.. automethod:: DirectSvc.route
\ No newline at end of file
plugin_dbui.directsvc.DirectSvc
===============================
.. currentmodule:: plugin_dbui.directsvc
.. autoclass:: DirectSvc
:show-inheritance:
.. rubric:: Methods
.. autosummary::
:toctree: directsvc/
~DirectSvc.dbg
~DirectSvc.echo
~DirectSvc.error
~DirectSvc.register
~DirectSvc.route
...@@ -42,29 +42,30 @@ class DirectSvc(BaseSvc): ...@@ -42,29 +42,30 @@ class DirectSvc(BaseSvc):
`web2py service <http://www.web2py.com/book/default/chapter/09>`_ `web2py service <http://www.web2py.com/book/default/chapter/09>`_
using a simplified version of the class ``gluon.tools.Service``. using a simplified version of the class ``gluon.tools.Service``.
To register functions and make them available on the client-side To functions have to registered in order to be available
use decorator:: on the client-side. The technique is based on *decorator*::
service = DirectSvc() service = DirectSvc()
@service.register @service.register
def myfunction(a, b): def myfunction(a, b):
The same technique can be used with methods. The same appraoch can be used for methods.
On the client-side: On the client-side:
* the API definition can be retrieved using the * the API definition can be retrieved at the
URL: ``/myapplication/plugin_dbui/call/get_api`` URL: ``/myapplication/plugin_dbui/call/get_api``
* the URL to send requests is * the URL to send requests is
``/myapplication/plugin_dbui/call`` ``/myapplication/plugin_dbui/call``
* remote functions and methods can be call in the * remote functions and methods are available in the
``Dbui`` name space. They can be call in the
following way ``Dbui.myfunction(a, b, callback)`` following way ``Dbui.myfunction(a, b, callback)``
and ``MyClass.mymethod(c, d, callback)`` respectively. and ``Dbui.MyClass.mymethod(c, d, callback)`` respectively.
In this implementation requests and response are JSON encoded. In this implementation requests and responses are JSON encoded.
Attributes: Attributes:
procedures (dict): procedures (dict):
...@@ -113,14 +114,14 @@ class DirectSvc(BaseSvc): ...@@ -113,14 +114,14 @@ class DirectSvc(BaseSvc):
def error(self, code, message): def error(self, code, message):
"""Build and raise the gluon.http.HTTP exception """Build and raise the ``gluon.http.HTTP`` exception.
Args: Args:
code (int): code of the HTTP error code (int): code of the HTTP error
message (str): explanation for the HTTP error message (str): explanation for the HTTP error
Raises: Raises:
gluon.http.HTTP: gluon.http.HTTP
""" """
raise HTTP(code, message) raise HTTP(code, message)
...@@ -129,7 +130,7 @@ class DirectSvc(BaseSvc): ...@@ -129,7 +130,7 @@ class DirectSvc(BaseSvc):
def register(self, f): def register(self, f):
""" Register a function/method. """ Register a function/method.
Example:: The technique relies on decorator::
service = DirectSvc() service = DirectSvc()
...@@ -140,8 +141,7 @@ class DirectSvc(BaseSvc): ...@@ -140,8 +141,7 @@ class DirectSvc(BaseSvc):
f (function): reference to a function f (function): reference to a function
Returns: Returns:
function: the input function
the input argument
""" """
# a procedure is registered as 'action.method' # a procedure is registered as 'action.method'
...@@ -159,8 +159,7 @@ class DirectSvc(BaseSvc): ...@@ -159,8 +159,7 @@ class DirectSvc(BaseSvc):
def route(self): def route(self):
"""Route the request to the appropriate function / method, """Route the request to the appropriate function / method.
pass the proper arguments and return the results.
Returns: Returns:
str: str:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment