[IMP] request add registry_cr helper

bzr revid: al@openerp.com-20130507182521-seuuzkd6uvuxc9xo
This commit is contained in:
Antony Lesuisse
2013-05-07 20:25:21 +02:00
parent aafd2a7fca
commit 4c579fe55e
+7
View File
@@ -118,6 +118,13 @@ class WebRequest(object):
# we use _ as seprator where RFC2616 uses '-'
self.lang = lang.replace('-', '_')
@contextlib.contextmanager
def registry_cr(self):
dbname = self.session._db or openerp.addons.web.controllers.main.db_monodb(self)
registry = openerp.modules.registry.Registry(dbname.lower())
with registry.cursor() as cr:
yield (registry, cr)
def reject_nonliteral(dct):
if '__ref' in dct:
raise ValueError(