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