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
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.
import addons
import cli
import conf
+import http
import loglevels
import modules
import netsvc
--- /dev/null
+# -*- 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:
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: