[FIX] http: `request.env` and request.cr` now raise `RuntimeError`.
These method used to raise an `AttributeError` when `self.registry` returns `None`. Now raises a more appropriated exception.
This commit is contained in:
parent
6e54c8d17a
commit
291119c802
|
@ -201,7 +201,11 @@ class WebRequest(object):
|
|||
def env(self):
|
||||
"""
|
||||
The :class:`~openerp.api.Environment` bound to current request.
|
||||
Raises a :class:`RuntimeError` if the current requests is not bound
|
||||
to a database.
|
||||
"""
|
||||
if not self.db:
|
||||
return RuntimeError('request not bound to a database')
|
||||
return openerp.api.Environment(self.cr, self.uid, self.context)
|
||||
|
||||
@lazy_property
|
||||
|
@ -236,6 +240,8 @@ class WebRequest(object):
|
|||
"""
|
||||
# can not be a lazy_property because manual rollback in _call_function
|
||||
# if already set (?)
|
||||
if not self.db:
|
||||
return RuntimeError('request not bound to a database')
|
||||
if not self._cr:
|
||||
self._cr = self.registry.cursor()
|
||||
return self._cr
|
||||
|
|
Loading…
Reference in New Issue