diff --git a/doc/howto/howto_website.rst b/doc/howto/howto_website.rst index cc1dba77995..0ca53e49610 100644 --- a/doc/howto/howto_website.rst +++ b/doc/howto/howto_website.rst @@ -512,7 +512,7 @@ new record, you can select records to delete them. There's one big issue to fix right now, the labeling of the column in the list and the fields in the form view, which are all currently :guilabel:`unknown`: -.. FIXME:: fix labels +.. FIXME fix labels .. create menu, action .. improve generated views diff --git a/openerp/http.py b/openerp/http.py index 72bb28ba92b..dcd20002a35 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -142,8 +142,8 @@ class WebRequest(object): initialization and setup of the request object (the dispatching itself has to be handled by the subclasses) - :param request: a wrapped werkzeug Request object - :type request: :class:`werkzeug.wrappers.BaseRequest` + :param httprequest: a wrapped werkzeug Request object + :type httprequest: :class:`werkzeug.wrappers.BaseRequest` .. attribute:: httprequest @@ -154,7 +154,7 @@ class WebRequest(object): .. deprecated:: 8.0 - Use ``self.session`` instead. + Use :attr:`session` instead. .. attribute:: params @@ -164,7 +164,7 @@ class WebRequest(object): .. attribute:: session_id - opaque identifier for the :class:`session.OpenERPSession` instance of + opaque identifier for the :class:`OpenERPSession` instance of the current request .. attribute:: session @@ -174,17 +174,18 @@ class WebRequest(object): .. attribute:: context - :class:`~collections.Mapping` of context values for the current request + :class:`~collections.Mapping` of context values for the current + request .. attribute:: db - ``str``, the name of the database linked to the current request. Can be ``None`` - if the current request uses the ``none`` authentication. + ``str``, the name of the database linked to the current request. Can + be ``None`` if the current request uses the ``none`` authentication. .. attribute:: uid - ``int``, the id of the user related to the current request. Can be ``None`` - if the current request uses the ``none`` authenticatoin. + ``int``, the id of the user related to the current request. Can be + ``None`` if the current request uses the ``none`` authentication. """ def __init__(self, httprequest): self.httprequest = httprequest @@ -214,24 +215,25 @@ class WebRequest(object): @property def registry(self): """ - The registry to the database linked to this request. Can be ``None`` if the current request uses the - ``none'' authentication. + The registry to the database linked to this request. Can be ``None`` + if the current request uses the ``none`` authentication. """ return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None @property def db(self): """ - The registry to the database linked to this request. Can be ``None`` if the current request uses the - ``none'' authentication. + The registry to the database linked to this request. Can be ``None`` + if the current request uses the ``none`` authentication. """ return self.session.db if not self.disable_db else None @property def cr(self): """ - The cursor initialized for the current method call. If the current request uses the ``none`` authentication - trying to access this property will raise an exception. + The cursor initialized for the current method call. If the current + request uses the ``none`` authentication trying to access this + property will raise an exception. """ # some magic to lazy create the cr if not self._cr: @@ -305,22 +307,29 @@ class WebRequest(object): def route(route=None, **kw): """ - Decorator marking the decorated method as being a handler for requests. The method must be part of a subclass - of ``Controller``. + Decorator marking the decorated method as being a handler for + requests. The method must be part of a subclass of ``Controller``. - :param route: string or array. The route part that will determine which http requests will match the decorated - method. Can be a single string or an array of strings. See werkzeug's routing documentation for the format of - route expression ( http://werkzeug.pocoo.org/docs/routing/ ). + :param route: string or array. The route part that will determine which + http requests will match the decorated method. Can be a + single string or an array of strings. See werkzeug's routing + documentation for the format of route expression ( + http://werkzeug.pocoo.org/docs/routing/ ). :param type: The type of request, can be ``'http'`` or ``'json'``. :param auth: The type of authentication method, can on of the following: - * ``user``: The user must be authenticated and the current request will perform using the rights of the - user. - * ``admin``: The user may not be authenticated and the current request will perform using the admin user. - * ``none``: The method is always active, even if there is no database. Mainly used by the framework and - authentication modules. There request code will not have any facilities to access the database nor have any - configuration indicating the current database nor the current user. - :param methods: A sequence of http methods this route applies to. If not specified, all methods are allowed. + * ``user``: The user must be authenticated and the current request + will perform using the rights of the user. + * ``admin``: The user may not be authenticated and the current request + will perform using the admin user. + * ``none``: The method is always active, even if there is no + database. Mainly used by the framework and authentication + modules. There request code will not have any facilities to access + the database nor have any configuration indicating the current + database nor the current user. + + :param methods: A sequence of http methods this route applies to. If not + specified, all methods are allowed. :param cors: The Access-Control-Allow-Origin cors directive value. """ routing = kw.copy() @@ -424,7 +433,7 @@ class JsonRequest(WebRequest): response = { 'jsonrpc': '2.0', 'id': self.jsonrequest.get('id') - } + } if error is not None: response['error'] = error if result is not None: @@ -505,8 +514,7 @@ def to_jsonable(o): def jsonrequest(f): """ .. deprecated:: 8.0 - - Use the ``route()`` decorator instead. + Use the :func:`~openerp.http.route` decorator instead. """ base = f.__name__.lstrip('/') if f.__name__ == "index": @@ -584,7 +592,7 @@ def httprequest(f): """ .. deprecated:: 8.0 - Use the ``route()`` decorator instead. + Use the :func:`~openerp.http.route` decorator instead. """ base = f.__name__.lstrip('/') if f.__name__ == "index": @@ -701,7 +709,7 @@ class SessionExpiredException(Exception): class Service(object): """ .. deprecated:: 8.0 - Use ``dispatch_rpc()`` instead. + Use :func:`dispatch_rpc` instead. """ def __init__(self, session, service_name): self.session = session @@ -716,7 +724,7 @@ class Service(object): class Model(object): """ .. deprecated:: 8.0 - Use the resistry and cursor in ``openerp.http.request`` instead. + Use the registry and cursor in :data:`request` instead. """ def __init__(self, session, model): self.session = session @@ -769,10 +777,12 @@ class OpenERPSession(werkzeug.contrib.sessions.Session): def authenticate(self, db, login=None, password=None, uid=None): """ - Authenticate the current user with the given db, login and password. If successful, store - the authentication parameters in the current session and request. + Authenticate the current user with the given db, login and + password. If successful, store the authentication parameters in the + current session and request. - :param uid: If not None, that user id will be used instead the login to authenticate the user. + :param uid: If not None, that user id will be used instead the login + to authenticate the user. """ if uid is None: @@ -797,9 +807,9 @@ class OpenERPSession(werkzeug.contrib.sessions.Session): def check_security(self): """ - Chech the current authentication parameters to know if those are still valid. This method - should be called at each request. If the authentication fails, a ``SessionExpiredException`` - is raised. + Check the current authentication parameters to know if those are still + valid. This method should be called at each request. If the + authentication fails, a :exc:`SessionExpiredException` is raised. """ if not self.db or not self.uid: raise SessionExpiredException("Session expired") @@ -820,9 +830,8 @@ class OpenERPSession(werkzeug.contrib.sessions.Session): def get_context(self): """ - Re-initializes the current user's session context (based on - his preferences) by calling res.users.get_context() with the old - context. + Re-initializes the current user's session context (based on his + preferences) by calling res.users.get_context() with the old context. :returns: the new context """ @@ -855,8 +864,8 @@ class OpenERPSession(werkzeug.contrib.sessions.Session): # Deprecated to be removed in 9 """ - Damn properties for retro-compatibility. All of that is deprecated, all - of that. + Damn properties for retro-compatibility. All of that is deprecated, + all of that. """ @property def _db(self): @@ -886,21 +895,21 @@ class OpenERPSession(werkzeug.contrib.sessions.Session): def send(self, service_name, method, *args): """ .. deprecated:: 8.0 - Use ``dispatch_rpc()`` instead. + Use :func:`dispatch_rpc` instead. """ return dispatch_rpc(service_name, method, args) def proxy(self, service): """ .. deprecated:: 8.0 - Use ``dispatch_rpc()`` instead. + Use :func:`dispatch_rpc` instead. """ return Service(self, service) def assert_valid(self, force=False): """ .. deprecated:: 8.0 - Use ``check_security()`` instead. + Use :meth:`check_security` instead. Ensures this session is valid (logged into the openerp server) """ @@ -914,7 +923,7 @@ class OpenERPSession(werkzeug.contrib.sessions.Session): def ensure_valid(self): """ .. deprecated:: 8.0 - Use ``check_security()`` instead. + Use :meth:`check_security` instead. """ if self.uid: try: @@ -925,7 +934,7 @@ class OpenERPSession(werkzeug.contrib.sessions.Session): def execute(self, model, func, *l, **d): """ .. deprecated:: 8.0 - Use the resistry and cursor in ``openerp.addons.web.http.request`` instead. + Use the registry and cursor in :data:`request` instead. """ model = self.model(model) r = getattr(model, func)(*l, **d) @@ -934,7 +943,7 @@ class OpenERPSession(werkzeug.contrib.sessions.Session): def exec_workflow(self, model, id, signal): """ .. deprecated:: 8.0 - Use the resistry and cursor in ``openerp.addons.web.http.request`` instead. + Use the registry and cursor in :data:`request` instead. """ self.assert_valid() r = self.proxy('object').exec_workflow(self.db, self.uid, self.password, model, signal, id) @@ -943,7 +952,7 @@ class OpenERPSession(werkzeug.contrib.sessions.Session): def model(self, model): """ .. deprecated:: 8.0 - Use the resistry and cursor in ``openerp.addons.web.http.request`` instead. + Use the registry and cursor in :data:`request` instead. Get an RPC proxy for the object ``model``, bound to this session. @@ -1126,8 +1135,8 @@ class Root(object): if statics: _logger.info("HTTP Configuring static files") - app = werkzeug.wsgi.SharedDataMiddleware(self.dispatch, statics) - self.dispatch = DisableCacheMiddleware(app) + app = werkzeug.wsgi.SharedDataMiddleware(self.dispatch, statics) + self.dispatch = DisableCacheMiddleware(app) def setup_session(self, httprequest): # recover or create session