[REF] openerp.service.{rpc,route,handler} decorators moved to openerp.http.
authorVo Minh Thu <vmt@openerp.com>
Fri, 1 Feb 2013 09:37:27 +0000 (10:37 +0100)
committerVo Minh Thu <vmt@openerp.com>
Fri, 1 Feb 2013 09:37:27 +0000 (10:37 +0100)
bzr revid: vmt@openerp.com-20130201093727-pgcvauuo87o2a3p6

doc/routing.rst
openerp/__init__.py
openerp/http.py [new file with mode: 0644]
openerp/service/__init__.py

index 1e4f76d..b2e93de 100644 (file)
@@ -3,6 +3,8 @@
 Routing
 =======
 
+.. versionchanged:: 7.1
+
 The OpenERP framework, as an HTTP server, serves a few hard-coded URLs
 (``models``, ``db``, ...) to expose RPC endpoints. When running the web addons
 (which is almost always the case), it also serves URLs without them being RPC
@@ -13,6 +15,6 @@ In older version of OpenERP, adding RPC endpoints was done by subclassing the
 registering them with the ``openerp.wsgi.register_wsgi_handler()`` function.
 
 Starting with OpenERP 7.1, exposing a new arbitrary WSGI handler is done with
-the ``openerp.service.handler`` decorator while adding an RPC endpoint is done
-with the ``openerp.service.rpc`` decorator.
+the ``openerp.http.handler`` decorator while adding an RPC endpoint is done
+with the ``openerp.http.rpc`` decorator.
 
index 307170b..dc09113 100644 (file)
@@ -28,6 +28,7 @@ SUPERUSER_ID = 1
 import addons
 import cli
 import conf
+import http
 import loglevels
 import modules
 import netsvc
diff --git a/openerp/http.py b/openerp/http.py
new file mode 100644 (file)
index 0000000..004542f
--- /dev/null
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+
+"""
+Decorators to register WSGI and RPC endpoints handlers. See doc/routing.rst.
+# TODO use sphinx ref to doc/routing.rst.
+"""
+
+from . import service
+
+def handler():
+    """
+    Decorator to register a WSGI handler. The handler must return None if it
+    does not handle the request.
+    """
+    def decorator(f):
+        service.wsgi_server.register_wsgi_handler(f)
+    return decorator
+
+def route(url):
+    """
+    Same as then handler() decorator but register the handler under a specific
+    url. Not yet implemented.
+    """
+    def decorator(f):
+        pass # TODO
+    return decorator
+
+def rpc(endpoint):
+    """
+    Decorator to register a RPC endpoint handler. The handler will receive
+    already unmarshalled RCP arguments.
+    """
+    def decorator(f):
+        service.wsgi_server.register_rpc_endpoint(endpoint, f)
+    return decorator
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index db5d454..9db7322 100644 (file)
@@ -150,22 +150,4 @@ def restart_server():
             openerp.phoenix = True
             os.kill(os.getpid(), signal.SIGINT)
 
-def handler():
-    """TODO"""
-    def decorator(f):
-        wsgi_server.register_wsgi_handler(f)
-    return decorator
-
-def route(url):
-    """TODO"""
-    def decorator(f):
-        pass # TODO Same as handler() but register the handler under a specific url.
-    return decorator
-
-def rpc(endpoint):
-    """TODO"""
-    def decorator(f):
-        wsgi_server.register_rpc_endpoint(endpoint, f)
-    return decorator
-
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: